Bug 1251655 - Remove support for JavaScript-DOM-class and JavaScript-DOM-interface. r=bz.

--HG--
extra : rebase_source : 88c93e93905e20d2f6755d67d86902fdfc923eb4
This commit is contained in:
Peter Van der Beken 2016-02-14 15:59:48 +01:00
parent 5564e12f54
commit 946ac27409
20 changed files with 41 additions and 919 deletions

View File

@ -93,7 +93,6 @@ EXPORTS += [
'nsIDocumentInlines.h',
'nsIDocumentObserver.h',
'nsIDOMClassInfo.h',
'nsIDOMScriptObjectFactory.h',
'nsIGlobalObject.h',
'nsImageLoadingContent.h',
'nsIMutationObserver.h',
@ -279,7 +278,6 @@ UNIFIED_SOURCES += [
'nsDOMClassInfo.cpp',
'nsDOMMutationObserver.cpp',
'nsDOMNavigationTiming.cpp',
'nsDOMScriptObjectFactory.cpp',
'nsDOMSerializer.cpp',
'nsDOMTokenList.cpp',
'nsDOMWindowList.cpp',

View File

@ -119,7 +119,6 @@
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNode.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIDOMWindowUtils.h"
#include "nsIDOMXULCommandEvent.h"
#include "nsIDragService.h"

View File

@ -26,6 +26,7 @@
#include "nscore.h"
#include "nsDOMClassInfo.h"
#include "nsIDOMClassInfo.h"
#include "nsCRT.h"
#include "nsCRTGlue.h"
#include "nsICategoryManager.h"
@ -117,8 +118,6 @@
using namespace mozilla;
using namespace mozilla::dom;
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
// NOTE: DEFAULT_SCRIPTABLE_FLAGS and DOM_DEFAULT_SCRIPTABLE_FLAGS
// are defined in nsIDOMClassInfo.h.
@ -140,7 +139,7 @@ static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
_chromeOnly, _allowXBL) \
{ #_class, \
nullptr, \
{ _helper::doCreate }, \
_helper::doCreate, \
nullptr, \
nullptr, \
nullptr, \
@ -352,15 +351,6 @@ nsDOMClassInfo::nsDOMClassInfo(nsDOMClassInfoData* aData) : mData(aData)
{
}
nsDOMClassInfo::~nsDOMClassInfo()
{
if (IS_EXTERNAL(mData->mCachedClassInfo)) {
// Some compilers don't like delete'ing a const nsDOMClassInfo*
nsDOMClassInfoData* data = const_cast<nsDOMClassInfoData*>(mData);
delete static_cast<nsExternalDOMClassInfoData*>(data);
}
}
NS_IMPL_ADDREF(nsDOMClassInfo)
NS_IMPL_RELEASE(nsDOMClassInfo)
@ -448,58 +438,6 @@ nsDOMClassInfo::RegisterClassProtos(int32_t aClassInfoID)
return NS_OK;
}
// static
nsresult
nsDOMClassInfo::RegisterExternalClasses()
{
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
nsCOMPtr<nsIComponentRegistrar> registrar;
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
NS_ENSURE_SUCCESS(rv, rv);
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 contractId;
nsAutoCString categoryEntry;
nsCOMPtr<nsISupports> entry;
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
if (!category) {
NS_WARNING("Category entry not an nsISupportsCString!");
continue;
}
rv = category->GetData(categoryEntry);
cm->GetCategoryEntry(JAVASCRIPT_DOM_CLASS, categoryEntry.get(),
getter_Copies(contractId));
NS_ENSURE_SUCCESS(rv, rv);
nsCID *cid;
rv = registrar->ContractIDToCID(contractId, &cid);
if (NS_FAILED(rv)) {
NS_WARNING("Bad contract id registered with the script namespace manager");
continue;
}
rv = nameSpaceManager->RegisterExternalClassName(categoryEntry.get(), *cid);
free(cid);
NS_ENSURE_SUCCESS(rv, rv);
}
return nameSpaceManager->RegisterExternalInterfaces(true);
}
#define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if) \
{ \
nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id]; \
@ -710,7 +648,7 @@ nsDOMClassInfo::Init()
#ifdef DEBUG
for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
if (!sClassInfoData[i].u.mConstructorFptr ||
if (!sClassInfoData[i].mConstructorFptr ||
sClassInfoData[i].mDebugID != i) {
MOZ_CRASH("Class info data out of sync, you forgot to update "
"nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
@ -745,8 +683,6 @@ nsDOMClassInfo::Init()
RegisterClassProtos(i);
}
RegisterExternalClasses();
sIsInitialized = true;
return NS_OK;
@ -978,41 +914,6 @@ nsDOMClassInfo::HasInstance(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_ERROR_UNEXPECTED;
}
static nsresult
GetExternalClassInfo(nsScriptNameSpaceManager *aNameSpaceManager,
const nsAString &aName,
const nsGlobalNameStruct *aStruct,
const nsGlobalNameStruct **aResult)
{
NS_ASSERTION(aStruct->mType ==
nsGlobalNameStruct::eTypeExternalClassInfoCreator,
"Wrong type!");
nsresult rv;
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(aStruct->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_ConvertUTF16toUTF8(aName).get(), sof);
NS_ENSURE_SUCCESS(rv, rv);
const nsGlobalNameStruct *name_struct = aNameSpaceManager->LookupName(aName);
if (name_struct &&
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
*aResult = name_struct;
}
else {
NS_ERROR("Couldn't get the DOM ClassInfo data.");
*aResult = nullptr;
}
return NS_OK;
}
static nsresult
ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
JS::Handle<JSObject*> obj, const char16_t *name,
@ -1134,48 +1035,20 @@ NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
if (!sClassInfoData[aID].mCachedClassInfo) {
nsDOMClassInfoData& data = sClassInfoData[aID];
data.mCachedClassInfo = data.u.mConstructorFptr(&data);
data.mCachedClassInfo = data.mConstructorFptr(&data);
NS_ENSURE_TRUE(data.mCachedClassInfo, nullptr);
NS_ADDREF(data.mCachedClassInfo);
}
NS_ASSERTION(!IS_EXTERNAL(sClassInfoData[aID].mCachedClassInfo),
"This is bad, internal class marked as external!");
return sClassInfoData[aID].mCachedClassInfo;
}
// 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->u.mExternalConstructorFptr) {
aData->mCachedClassInfo =
aData->u.mExternalConstructorFptr(aData->mName);
} else {
aData->mCachedClassInfo = nsDOMGenericSH::doCreate(aData);
}
NS_ENSURE_TRUE(aData->mCachedClassInfo, nullptr);
NS_ADDREF(aData->mCachedClassInfo);
aData->mCachedClassInfo = MARK_EXTERNAL(aData->mCachedClassInfo);
}
return GET_CLEAN_CI_PTR(aData->mCachedClassInfo);
}
// static
void
nsDOMClassInfo::ShutDown()
{
if (sClassInfoData[0].u.mConstructorFptr) {
if (sClassInfoData[0].mConstructorFptr) {
uint32_t i;
for (i = 0; i < eDOMClassInfoIDCount; i++) {
@ -1202,10 +1075,10 @@ BaseStubConstructor(nsIWeakReference* aWeakOwner,
nsCOMPtr<nsISupports> native;
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
rv = NS_ERROR_NOT_AVAILABLE;
} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
native = do_CreateInstance(name_struct->mCID, &rv);
} else {
native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);
MOZ_ASSERT(name_struct->mType ==
nsGlobalNameStruct::eTypeExternalConstructor);
native = do_CreateInstance(name_struct->mCID, &rv);
}
if (NS_FAILED(rv)) {
NS_ERROR("Failed to create the object");
@ -1277,7 +1150,6 @@ protected:
public:
static nsresult Create(const char16_t* aName,
const nsDOMClassInfoData* aData,
const nsGlobalNameStruct* aNameStruct,
nsPIDOMWindowInner* aOwner,
nsDOMConstructor** aResult);
@ -1333,24 +1205,9 @@ private:
return NS_OK;
}
static bool IsConstructable(const nsDOMClassInfoData *aData)
{
if (IS_EXTERNAL(aData->mCachedClassInfo)) {
const nsExternalDOMClassInfoData* data =
static_cast<const nsExternalDOMClassInfoData*>(aData);
return data->mConstructorCID != nullptr;
}
return false;
}
static bool IsConstructable(const nsGlobalNameStruct *aNameStruct)
{
return
(aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor &&
IsConstructable(&sClassInfoData[aNameStruct->mDOMClassInfoID])) ||
(aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo &&
IsConstructable(aNameStruct->mData)) ||
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor;
return aNameStruct->mType == nsGlobalNameStruct::eTypeExternalConstructor;
}
const char16_t* mClassName;
@ -1361,7 +1218,6 @@ private:
//static
nsresult
nsDOMConstructor::Create(const char16_t* aName,
const nsDOMClassInfoData* aData,
const nsGlobalNameStruct* aNameStruct,
nsPIDOMWindowInner* aOwner,
nsDOMConstructor** aResult)
@ -1382,9 +1238,7 @@ nsDOMConstructor::Create(const char16_t* aName,
return NS_ERROR_DOM_SECURITY_ERR;
}
bool constructable = aNameStruct ?
IsConstructable(aNameStruct) :
IsConstructable(aData);
bool constructable = aNameStruct && IsConstructable(aNameStruct);
*aResult = new nsDOMConstructor(aName, constructable, currentInner);
NS_ADDREF(*aResult);
@ -1510,8 +1364,7 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
return NS_OK;
}
if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) {
if (name_struct->mType != nsGlobalNameStruct::eTypeClassConstructor) {
// Doesn't have DOM interfaces.
return NS_OK;
}
@ -1526,30 +1379,26 @@ nsDOMConstructor::HasInstance(nsIXPConnectWrappedNative *wrapper,
}
const nsIID *class_iid;
if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
class_iid = &class_name_struct->mIID;
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
class_iid =
sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
class_iid = class_name_struct->mData->mProtoChainInterface;
} else {
*bp = false;
return NS_OK;
}
NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
NS_ASSERTION(name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor,
"The constructor was set up with a struct of the wrong type.");
const nsDOMClassInfoData *ci_data = nullptr;
const nsDOMClassInfoData *ci_data;
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;
} else {
ci_data = nullptr;
}
nsCOMPtr<nsIInterfaceInfoManager>
@ -1593,14 +1442,11 @@ nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*>
return NS_ERROR_UNEXPECTED;
const nsIID *class_iid;
if (class_name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassProto) {
class_iid = &class_name_struct->mIID;
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
class_iid =
sClassInfoData[class_name_struct->mDOMClassInfoID].mProtoChainInterface;
} else if (class_name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
class_iid = class_name_struct->mData->mProtoChainInterface;
} else {
return NS_OK;
}
@ -1627,23 +1473,15 @@ GetXPCProto(nsIXPConnect *aXPConnect, JSContext *cx, nsGlobalWindow *aWin,
const nsGlobalNameStruct *aNameStruct,
JS::MutableHandle<JSObject*> aProto)
{
NS_ASSERTION(aNameStruct->mType ==
nsGlobalNameStruct::eTypeClassConstructor ||
aNameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo,
NS_ASSERTION(aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor,
"Wrong type!");
nsCOMPtr<nsIClassInfo> ci;
if (aNameStruct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
int32_t id = aNameStruct->mDOMClassInfoID;
MOZ_ASSERT(id >= 0, "Negative DOM classinfo?!?");
int32_t id = aNameStruct->mDOMClassInfoID;
MOZ_ASSERT(id >= 0, "Negative DOM classinfo?!?");
nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
nsDOMClassInfoID ci_id = (nsDOMClassInfoID)id;
ci = NS_GetDOMClassInfoInstance(ci_id);
}
else {
ci = nsDOMClassInfo::GetClassInfoInstance(aNameStruct->mData);
}
nsCOMPtr<nsIClassInfo> ci = NS_GetDOMClassInfoInstance(ci_id);
NS_ENSURE_TRUE(ci, NS_ERROR_UNEXPECTED);
nsresult rv =
@ -1671,8 +1509,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
"Wrong type or missing ci_data!");
RefPtr<nsDOMConstructor> constructor;
nsresult rv = nsDOMConstructor::Create(name, ci_data, name_struct,
aWin->AsInner(),
nsresult rv = nsDOMConstructor::Create(name, name_struct, aWin->AsInner(),
getter_AddRefs(constructor));
NS_ENSURE_SUCCESS(rv, rv);
@ -1825,8 +1662,7 @@ OldBindingConstructorEnabled(const nsGlobalNameStruct *aStruct,
nsGlobalWindow *aWin, JSContext *cx)
{
MOZ_ASSERT(aStruct->mType == nsGlobalNameStruct::eTypeProperty ||
aStruct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
aStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfo);
aStruct->mType == nsGlobalNameStruct::eTypeClassConstructor);
// Don't expose chrome only constructors to content windows.
if (aStruct->mChromeOnly) {
@ -1857,17 +1693,8 @@ nsWindowSH::NameStructEnabled(JSContext* aCx, nsGlobalWindow *aWin,
const nsGlobalNameStruct& aNameStruct)
{
const nsGlobalNameStruct* nameStruct = &aNameStruct;
if (nameStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
nsresult rv = GetExternalClassInfo(GetNameSpaceManager(), aName, nameStruct,
&nameStruct);
if (NS_FAILED(rv) || !nameStruct) {
return false;
}
}
return (nameStruct->mType != nsGlobalNameStruct::eTypeProperty &&
nameStruct->mType != nsGlobalNameStruct::eTypeClassConstructor &&
nameStruct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) ||
nameStruct->mType != nsGlobalNameStruct::eTypeClassConstructor) ||
OldBindingConstructorEnabled(nameStruct, aWin, aCx);
}
@ -1937,16 +1764,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
nsresult rv = NS_OK;
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
rv = GetExternalClassInfo(nameSpaceManager, name, name_struct,
&name_struct);
if (NS_FAILED(rv) || !name_struct) {
return rv;
}
}
if (name_struct->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
name_struct->mType == nsGlobalNameStruct::eTypeInterface ||
name_struct->mType == nsGlobalNameStruct::eTypeClassProto ||
name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
// Lookup new DOM bindings.
@ -2038,45 +1856,7 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
}
}
if (name_struct->mType == nsGlobalNameStruct::eTypeInterface) {
// We're resolving a name of a DOM interface for which there is no
// direct DOM class, create a constructor object...
RefPtr<nsDOMConstructor> constructor;
rv = nsDOMConstructor::Create(class_name,
nullptr,
name_struct,
aWin->AsInner(),
getter_AddRefs(constructor));
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JS::Value> v(cx);
js::AssertSameCompartment(cx, obj);
rv = nsContentUtils::WrapNative(cx, constructor,
&NS_GET_IID(nsIDOMDOMConstructor), &v,
false);
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> class_obj(cx, &v.toObject());
// ... and define the constants from the DOM interface on that
// constructor object.
{
JSAutoCompartment ac(cx, class_obj);
rv = DefineInterfaceConstants(cx, class_obj, &name_struct->mIID);
NS_ENSURE_SUCCESS(rv, rv);
}
if (!JS_WrapValue(cx, &v)) {
return NS_ERROR_UNEXPECTED;
}
FillPropertyDescriptor(desc, obj, 0, v);
return NS_OK;
}
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor ||
name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
if (!OldBindingConstructorEnabled(name_struct, aWin, cx)) {
return NS_OK;
}
@ -2100,15 +1880,9 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
// This is the Xray case. Look up the constructor object for this
// prototype.
const nsDOMClassInfoData *ci_data;
if (name_struct->mType == nsGlobalNameStruct::eTypeClassConstructor) {
ci_data = &sClassInfoData[name_struct->mDOMClassInfoID];
} else {
ci_data = name_struct->mData;
}
return ResolvePrototype(nsDOMClassInfo::sXPConnect, aWin, cx, obj,
class_name, ci_data,
class_name,
&sClassInfoData[name_struct->mDOMClassInfoID],
name_struct, nameSpaceManager, dot_prototype,
desc);
}
@ -2123,8 +1897,8 @@ nsWindowSH::GlobalResolve(nsGlobalWindow *aWin, JSContext *cx,
if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
RefPtr<nsDOMConstructor> constructor;
rv = nsDOMConstructor::Create(class_name, nullptr, name_struct,
aWin->AsInner(), getter_AddRefs(constructor));
rv = nsDOMConstructor::Create(class_name, name_struct, aWin->AsInner(),
getter_AddRefs(constructor));
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JS::Value> val(cx);

View File

@ -8,9 +8,9 @@
#define nsDOMClassInfo_h___
#include "mozilla/Attributes.h"
#include "nsDOMClassInfoID.h"
#include "nsIXPCScriptable.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMScriptObjectFactory.h"
#include "js/Id.h"
#include "nsIXPConnect.h"
@ -32,13 +32,9 @@ struct nsDOMClassInfoData
{
const char *mName;
const char16_t *mNameUTF16;
union {
nsDOMClassInfoConstructorFnc mConstructorFptr;
nsDOMClassInfoExternalConstructorFnc mExternalConstructorFptr;
} u;
nsDOMClassInfoConstructorFnc mConstructorFptr;
nsIClassInfo *mCachedClassInfo; // low bit is set to 1 if external,
// so be sure to mask if necessary!
nsIClassInfo *mCachedClassInfo;
const nsIID *mProtoChainInterface;
const nsIID **mInterfaces;
uint32_t mScriptableFlags : 31; // flags must not use more than 31 bits!
@ -51,19 +47,6 @@ struct nsDOMClassInfoData
#endif
};
struct nsExternalDOMClassInfoData : public nsDOMClassInfoData
{
const nsCID *mConstructorCID;
};
// 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*)(uintptr_t(_ptr) & ~0x1)
#define MARK_EXTERNAL(_ptr) (nsIClassInfo*)(uintptr_t(_ptr) | 0x1)
#define IS_EXTERNAL(_ptr) (uintptr_t(_ptr) & 0x1)
class nsWindowSH;
class nsDOMClassInfo : public nsXPCClassInfo
@ -71,7 +54,7 @@ class nsDOMClassInfo : public nsXPCClassInfo
friend class nsWindowSH;
protected:
virtual ~nsDOMClassInfo();
virtual ~nsDOMClassInfo() {};
public:
explicit nsDOMClassInfo(nsDOMClassInfoData* aData);
@ -82,17 +65,6 @@ public:
NS_DECL_NSICLASSINFO
// Helper method that returns a *non* refcounted pointer to a
// helper. So please note, don't release this pointer, if you do,
// you better make sure you've addreffed before release.
//
// Whaaaaa! I wanted to name this method GetClassInfo, but nooo,
// some of Microsoft devstudio's headers #defines GetClassInfo to
// GetClassInfoA so I can't, those $%#@^! bastards!!! What gives
// them the right to do that?
static nsIClassInfo* GetClassInfoInstance(nsDOMClassInfoData* aData);
static nsresult Init();
static void ShutDown();
@ -134,7 +106,6 @@ protected:
}
static nsresult RegisterClassProtos(int32_t aDOMClassInfoID);
static nsresult RegisterExternalClasses();
static nsIXPConnect *sXPConnect;

View File

@ -60,10 +60,6 @@ NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
} \
} else
#else
// See nsIDOMClassInfo.h
#endif // MOZILLA_INTERNAL_API
#endif // nsDOMClassInfoID_h__

View File

@ -1,127 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*
* This Original Code has been modified by IBM Corporation.
* Modifications made by IBM described herein are
* Copyright (c) International Business Machines
* Corporation, 2000
*
* Modifications to Mozilla code or documentation
* identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
* use in OS2
*/
#include "nsDOMScriptObjectFactory.h"
#include "nsScriptNameSpaceManager.h"
#include "nsIObserverService.h"
#include "nsJSEnvironment.h"
#include "nsGlobalWindow.h"
#include "nsCRT.h"
#ifdef MOZ_XUL
#include "nsXULPrototypeCache.h"
#endif
#include "nsThreadUtils.h"
using mozilla::dom::GetNameSpaceManager;
nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
{
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
}
}
NS_INTERFACE_MAP_BEGIN(nsDOMScriptObjectFactory)
NS_INTERFACE_MAP_ENTRY(nsIDOMScriptObjectFactory)
NS_INTERFACE_MAP_ENTRY(nsIObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScriptObjectFactory)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsDOMScriptObjectFactory)
NS_IMPL_RELEASE(nsDOMScriptObjectFactory)
NS_IMETHODIMP_(nsISupports *)
nsDOMScriptObjectFactory::GetClassInfoInstance(nsDOMClassInfoID aID)
{
return NS_GetDOMClassInfoInstance(aID);
}
NS_IMETHODIMP_(nsISupports *)
nsDOMScriptObjectFactory::GetExternalClassInfoInstance(const nsAString& aName)
{
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
NS_ENSURE_TRUE(nameSpaceManager, nullptr);
const nsGlobalNameStruct *globalStruct = nameSpaceManager->LookupName(aName);
if (globalStruct) {
if (globalStruct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {
nsresult rv;
nsCOMPtr<nsIDOMCIExtension> creator(do_CreateInstance(globalStruct->mCID, &rv));
NS_ENSURE_SUCCESS(rv, nullptr);
rv = creator->RegisterDOMCI(NS_ConvertUTF16toUTF8(aName).get(), this);
NS_ENSURE_SUCCESS(rv, nullptr);
globalStruct = nameSpaceManager->LookupName(aName);
NS_ENSURE_TRUE(globalStruct, nullptr);
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 nullptr;
}
NS_IMETHODIMP
nsDOMScriptObjectFactory::Observe(nsISupports *aSubject,
const char *aTopic,
const char16_t *someData)
{
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
#ifdef MOZ_XUL
// Flush the XUL cache since it holds JS roots, and we're about to
// start the final GC.
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (cache)
cache->Flush();
#endif
}
return NS_OK;
}
NS_IMETHODIMP
nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
const nsIID *aProtoChainInterface,
const nsIID **aInterfaces,
uint32_t aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID)
{
nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
return nameSpaceManager->RegisterDOMCIData(aName,
aConstructorFptr,
aProtoChainInterface,
aInterfaces,
aScriptableFlags,
aHasClassInterface,
aConstructorCID);
}

View File

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*
* This Original Code has been modified by IBM Corporation.
* Modifications made by IBM described herein are
* Copyright (c) International Business Machines
* Corporation, 2000
*
* Modifications to Mozilla code or documentation
* identified per MPL Section 3.3
*
* Date Modified by Description of modification
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
* use in OS2
*/
#include "nsIDOMScriptObjectFactory.h"
#include "nsIObserver.h"
#include "mozilla/Attributes.h"
class nsDOMScriptObjectFactory final : public nsIDOMScriptObjectFactory,
public nsIObserver
{
~nsDOMScriptObjectFactory() {}
public:
nsDOMScriptObjectFactory();
NS_DECL_ISUPPORTS
// nsIObserver
NS_DECL_NSIOBSERVER
// nsIDOMScriptObjectFactory
NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) override;
NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName) override;
NS_IMETHOD RegisterDOMClassInfo(const char *aName,
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
const nsIID *aProtoChainInterface,
const nsIID **aInterfaces,
uint32_t aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID) override;
};

View File

@ -11,6 +11,7 @@
#include "AppProcessChecker.h"
#include "ContentChild.h"
#include "nsContentUtils.h"
#include "nsDOMClassInfoID.h"
#include "nsError.h"
#include "nsIXPConnect.h"
#include "jsapi.h"

View File

@ -7,12 +7,7 @@
#ifndef nsIDOMClassInfo_h___
#define nsIDOMClassInfo_h___
#include "nsIClassInfoImpl.h"
#include "nsDOMClassInfoID.h"
#include "nsIXPCScriptable.h"
#include "nsIServiceManager.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsDOMCID.h"
#define DOM_BASE_SCRIPTABLE_FLAGS \
(nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY | \
@ -32,153 +27,4 @@
nsIXPCScriptable::DONT_ENUM_QUERY_INTERFACE | \
nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY)
#ifdef MOZILLA_INTERNAL_API
// See nsDOMClassInfoID.h
#else
#define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class) \
if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
\
nsresult rv; \
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
&rv)); \
if (NS_FAILED(rv)) { \
*aInstancePtr = nullptr; \
return rv; \
} \
\
foundInterface = \
sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
} else
#endif /* MOZILLA_INTERNAL_API */
// 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)) || \
aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
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); \
\
nsresult rv; \
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
&rv)); \
if (NS_FAILED(rv)) { \
*aInstancePtr = nullptr; \
return rv; \
} \
\
foundInterface = \
sof->GetExternalClassInfoInstance(NS_LITERAL_STRING(#_class)); \
\
if (foundInterface) { \
NS_CLASSINFO_NAME(_class) = foundInterface; \
NS_CLASSINFO_NAME(_class)->AddRef(); \
} \
} \
} else
#define NS_DECL_DOM_CLASSINFO(_class) \
nsISupports *NS_CLASSINFO_NAME(_class) = nullptr;
// {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_DECLARE_STATIC_IID_ACCESSOR(NS_IDOMCI_EXTENSION_IID)
NS_IMETHOD RegisterDOMCI(const char* aName,
nsIDOMScriptObjectFactory* aDOMSOFactory) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMCIExtension, NS_IDOMCI_EXTENSION_IID)
#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_DOMCI_EXTENSION_NAME(_module)::~NS_DOMCI_EXTENSION_NAME(_module)() \
{ \
} \
\
NS_IMPL_ISUPPORTS(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) \
nullptr \
}; \
aDOMSOFactory->RegisterDOMClassInfo(#_class, nullptr, _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, nullptr, _hasclassif, \
_constructorcid)
#define NS_DOMCI_EXTENSION_END \
return NS_ERROR_FAILURE; \
}
#endif /* nsIDOMClassInfo_h___ */

View File

@ -1,45 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsIDOMScriptObjectFactory_h__
#define nsIDOMScriptObjectFactory_h__
#include "nsISupports.h"
#include "nsIDOMClassInfo.h"
#include "nsString.h"
#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
{ 0x2a50e17c, 0x46ff, 0x4150, \
{ 0xbb, 0x46, 0xd8, 0x07, 0xb3, 0x36, 0xde, 0xab } }
typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
(const char* aName);
class nsIDOMScriptObjectFactory : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
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,
uint32_t aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,
NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
#endif /* nsIDOMScriptObjectFactory_h__ */

View File

@ -20,10 +20,4 @@
#define JAVASCRIPT_NAVIGATOR_PROPERTY_CATEGORY \
"JavaScript-navigator-property"
#define JAVASCRIPT_DOM_CLASS \
"JavaScript-DOM-class"
#define JAVASCRIPT_DOM_INTERFACE \
"JavaScript-DOM-interface"
#endif /* nsIScriptNameSpaceManager_h__ */

View File

@ -2562,8 +2562,6 @@ AsmJSCacheOpenEntryForWrite(JS::Handle<JSObject*> aGlobal,
aSize, aMemory, aHandle);
}
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
void
nsJSContext::EnsureStatics()
{
@ -2695,15 +2693,6 @@ nsJSContext::EnsureStatics()
obs->AddObserver(observer, "quit-application", false);
obs->AddObserver(observer, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
// Bug 907848 - We need to explicitly get the nsIDOMScriptObjectFactory
// service in order to force its constructor to run, which registers a
// shutdown observer. It would be nice to make this more explicit and less
// side-effect-y.
nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
if (!factory) {
MOZ_CRASH();
}
sIsInitialized = true;
}

View File

@ -61,18 +61,6 @@ 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->u.mExternalConstructorFptr) {
delete e->mGlobalName.mData;
}
// Release our pointer to the helper.
NS_IF_RELEASE(ci);
}
// This will set e->mGlobalName.mType to
// nsGlobalNameStruct::eTypeNotInitialized
@ -169,116 +157,6 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
}
nsresult
nsScriptNameSpaceManager::RegisterExternalInterfaces(bool aAsProto)
{
nsresult rv;
nsCOMPtr<nsICategoryManager> cm =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInterfaceInfoManager>
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
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;
nsAutoCString category_entry;
const char* if_name;
nsCOMPtr<nsISupports> entry;
nsCOMPtr<nsIInterfaceInfo> if_info;
bool found_old, dom_prefix;
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
if (!category) {
NS_WARNING("Category entry not an nsISupportsCString!");
continue;
}
rv = category->GetData(category_entry);
NS_ENSURE_SUCCESS(rv, rv);
rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry.get(),
getter_Copies(IID_string));
NS_ENSURE_SUCCESS(rv, rv);
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;
}
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) {
name = if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1;
} else {
name = if_name + sizeof(NS_INTERFACE_PREFIX) - 1;
}
if (aAsProto) {
RegisterClassProto(name, iid, &found_old);
} else {
RegisterInterface(name, iid, &found_old);
}
if (found_old) {
break;
}
nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
tmp->GetParent(getter_AddRefs(if_info));
}
}
return NS_OK;
}
nsresult
nsScriptNameSpaceManager::RegisterInterface(const char* aIfName,
const nsIID *aIfIID,
bool* aFoundOld)
{
*aFoundOld = false;
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, aIfName);
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) {
*aFoundOld = true;
return NS_OK;
}
s->mType = nsGlobalNameStruct::eTypeInterface;
s->mIID = *aIfIID;
return NS_OK;
}
nsresult
nsScriptNameSpaceManager::Init()
{
@ -286,9 +164,6 @@ nsScriptNameSpaceManager::Init()
nsresult rv = NS_OK;
rv = RegisterExternalInterfaces(false);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsICategoryManager> cm =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
@ -371,8 +246,7 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
}
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding ||
s->mType == nsGlobalNameStruct::eTypeInterface,
s->mType == nsGlobalNameStruct::eTypeNewDOMBinding,
"Whaaa, JS environment name clash!");
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
@ -396,8 +270,7 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding &&
s->mType != nsGlobalNameStruct::eTypeInterface) {
s->mType != nsGlobalNameStruct::eTypeNewDOMBinding) {
*aFoundOld = true;
return NS_OK;
@ -409,77 +282,6 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
return NS_OK;
}
nsresult
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
nsCID& aCID)
{
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, 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::eTypeNewDOMBinding ||
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,
uint32_t aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID)
{
const char16_t* className;
nsGlobalNameStruct *s = AddToHash(&mGlobalNames, aName, &className);
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::eTypeNewDOMBinding ||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator,
"Someone tries to register classinfo data for a class that isn't new or external!");
s->mData = new nsExternalDOMClassInfoData;
s->mType = nsGlobalNameStruct::eTypeExternalClassInfo;
s->mData->mName = aName;
s->mData->mNameUTF16 = className;
if (aConstructorFptr)
s->mData->u.mExternalConstructorFptr = aConstructorFptr;
else
// null constructor will cause us to use nsDOMGenericSH::doCreate
s->mData->u.mExternalConstructorFptr = nullptr;
s->mData->mCachedClassInfo = nullptr;
s->mData->mProtoChainInterface = aProtoChainInterface;
s->mData->mInterfaces = aInterfaces;
s->mData->mScriptableFlags = aScriptableFlags;
s->mData->mHasClassInterface = aHasClassInterface;
s->mData->mConstructorCID = aConstructorCID;
return NS_OK;
}
nsresult
nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategoryManager,
const char* aCategory,

View File

@ -39,14 +39,11 @@ struct nsGlobalNameStruct
enum nametype {
eTypeNotInitialized,
eTypeNewDOMBinding,
eTypeInterface,
eTypeProperty,
eTypeNavigatorProperty,
eTypeExternalConstructor,
eTypeClassConstructor,
eTypeClassProto,
eTypeExternalClassInfoCreator,
eTypeExternalClassInfo,
} mType;
// mChromeOnly is only used for structs that define non-WebIDL things
@ -57,8 +54,7 @@ struct nsGlobalNameStruct
union {
int32_t mDOMClassInfoID; // eTypeClassConstructor
nsIID mIID; // eTypeInterface, eTypeClassProto
nsExternalDOMClassInfoData* mData; // eTypeExternalClassInfo
nsIID mIID; // eTypeClassProto
nsCID mCID; // All other types except eTypeNewDOMBinding
};
@ -128,21 +124,6 @@ public:
const nsIID *aConstructorProtoIID,
bool *aFoundOld);
nsresult RegisterExternalInterfaces(bool 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,
uint32_t aScriptableFlags,
bool aHasClassInterface,
const nsCID *aConstructorCID);
void RegisterDefineDOMInterface(const nsAFlatString& aName,
mozilla::dom::DefineInterface aDefineDOMInterface,
mozilla::dom::ConstructorEnabled* aConstructorEnabled);

View File

@ -38,7 +38,6 @@
#include "nsWrapperCacheInlines.h"
#include "nsIXPConnect.h"
#include "nsDOMCID.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsIScriptGlobalObject.h"
#include "nsTHashtable.h"

View File

@ -12,7 +12,6 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsIScriptContext.h"
#include "nsIDOMDocument.h"
#include "nsIDOMScriptObjectFactory.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "nsIURI.h"

View File

@ -36,7 +36,6 @@
#include "nsReadableUtils.h"
#include "nsGkAtoms.h"
#include "nsIXPConnect.h"
#include "nsIDOMScriptObjectFactory.h"
#include "mozilla/AddonPathService.h"
#include "nsDOMCID.h"
#include "nsUnicharUtils.h"

View File

@ -103,6 +103,7 @@ nsXULPrototypeCache::GetInstance()
nsXULPrototypeCache *p = sInstance;
obsSvc->AddObserver(p, "chrome-flush-skin-caches", false);
obsSvc->AddObserver(p, "chrome-flush-caches", false);
obsSvc->AddObserver(p, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
obsSvc->AddObserver(p, "startupcache-invalidate", false);
}
@ -120,7 +121,8 @@ nsXULPrototypeCache::Observe(nsISupports* aSubject,
if (!strcmp(aTopic, "chrome-flush-skin-caches")) {
FlushSkinFiles();
}
else if (!strcmp(aTopic, "chrome-flush-caches")) {
else if (!strcmp(aTopic, "chrome-flush-caches") ||
!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
Flush();
}
else if (!strcmp(aTopic, "startupcache-invalidate")) {

View File

@ -22,7 +22,6 @@
#include "nsString.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "nsIDOMScriptObjectFactory.h"
#include "nsDOMCID.h"
#include "nsNodeInfoManager.h"
#include "nsContentUtils.h"

View File

@ -75,7 +75,6 @@
#include "nsJSProtocolHandler.h"
#include "nsScriptNameSpaceManager.h"
#include "nsIControllerContext.h"
#include "nsDOMScriptObjectFactory.h"
#include "DOMStorageManager.h"
#include "nsJSON.h"
#include "nsZipArchive.h"
@ -624,8 +623,6 @@ _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
return rv; \
} \
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMScriptObjectFactory)
#define NS_GEOLOCATION_CID \
{ 0x1E1C3FF, 0x94A, 0xD048, { 0x44, 0xB4, 0x62, 0xD2, 0x9C, 0x7B, 0x4F, 0x39 } }
@ -746,7 +743,6 @@ NS_DEFINE_NAMED_CID(NS_XULTREEBUILDER_CID);
NS_DEFINE_NAMED_CID(NS_XULDOCUMENT_CID);
#endif
NS_DEFINE_NAMED_CID(NS_CONTENT_DOCUMENT_LOADER_FACTORY_CID);
NS_DEFINE_NAMED_CID(NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
NS_DEFINE_NAMED_CID(NS_JSPROTOCOLHANDLER_CID);
NS_DEFINE_NAMED_CID(NS_JSURI_CID);
NS_DEFINE_NAMED_CID(NS_WINDOWCOMMANDTABLE_CID);
@ -1058,7 +1054,6 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kNS_XULDOCUMENT_CID, false, nullptr, CreateXULDocument },
#endif
{ &kNS_CONTENT_DOCUMENT_LOADER_FACTORY_CID, false, nullptr, CreateContentDLF },
{ &kNS_DOM_SCRIPT_OBJECT_FACTORY_CID, false, nullptr, nsDOMScriptObjectFactoryConstructor },
{ &kNS_JSPROTOCOLHANDLER_CID, false, nullptr, nsJSProtocolHandler::Create },
{ &kNS_JSURI_CID, false, nullptr, nsJSURIConstructor },
{ &kNS_WINDOWCOMMANDTABLE_CID, false, nullptr, CreateWindowCommandTableConstructor },