зеркало из https://github.com/mozilla/pjs.git
Bug 735280 - Part 2: Add pre-create to nsXPComponents. r=bholley
This commit is contained in:
Родитель
83b80ef327
Коммит
404a89cdd5
|
@ -4193,7 +4193,8 @@ NS_IMETHODIMP
|
|||
nsXPCComponents::GetHelperForLanguage(PRUint32 language,
|
||||
nsISupports **retval)
|
||||
{
|
||||
*retval = nsnull;
|
||||
*retval = static_cast<nsIXPCComponents*>(this);
|
||||
NS_ADDREF(this);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -4341,6 +4342,7 @@ nsXPCComponents::GetManager(nsIComponentManager * *aManager)
|
|||
#define XPC_MAP_WANT_NEWRESOLVE
|
||||
#define XPC_MAP_WANT_GETPROPERTY
|
||||
#define XPC_MAP_WANT_SETPROPERTY
|
||||
#define XPC_MAP_WANT_PRECREATE
|
||||
#define XPC_MAP_FLAGS nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
|
||||
#include "xpc_map_end.h" /* This will #undef the above */
|
||||
|
||||
|
@ -4429,16 +4431,20 @@ nsXPCComponents::SetProperty(nsIXPConnectWrappedNative *wrapper,
|
|||
|
||||
// static
|
||||
JSBool
|
||||
nsXPCComponents::AttachNewComponentsObject(XPCCallContext& ccx,
|
||||
XPCWrappedNativeScope* aScope,
|
||||
JSObject* aGlobal)
|
||||
nsXPCComponents::AttachComponentsObject(XPCCallContext& ccx,
|
||||
XPCWrappedNativeScope* aScope,
|
||||
JSObject* aGlobal)
|
||||
{
|
||||
if (!aGlobal)
|
||||
return false;
|
||||
|
||||
nsXPCComponents* components = new nsXPCComponents(aScope);
|
||||
if (!components)
|
||||
return false;
|
||||
nsXPCComponents* components = aScope->GetComponents();
|
||||
if (!components) {
|
||||
components = new nsXPCComponents(aScope);
|
||||
if (!components)
|
||||
return false;
|
||||
aScope->SetComponents(components);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIXPCComponents> cholder(components);
|
||||
|
||||
|
@ -4454,8 +4460,6 @@ nsXPCComponents::AttachNewComponentsObject(XPCCallContext& ccx,
|
|||
if (!wrapper)
|
||||
return false;
|
||||
|
||||
aScope->SetComponents(components);
|
||||
|
||||
jsid id = ccx.GetRuntime()->GetStringID(XPCJSRuntime::IDX_COMPONENTS);
|
||||
JSObject* obj;
|
||||
|
||||
|
@ -4530,3 +4534,15 @@ nsXPCComponents::CanSetProperty(const nsIID * iid, const PRUnichar *propertyName
|
|||
*_retval = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPCComponents::PreCreate(nsISupports *nativeObj, JSContext *cx, JSObject *globalObj, JSObject **parentObj)
|
||||
{
|
||||
// this should never happen
|
||||
if (!mScope) {
|
||||
NS_WARNING("mScope must not be null when nsXPCComponents::PreCreate is called");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
*parentObj = mScope->GetGlobalJSObject();
|
||||
return NS_OK;
|
||||
}
|
|
@ -1020,7 +1020,7 @@ nsXPConnect::InitClasses(JSContext * aJSContext, JSObject * aGlobalJSObj)
|
|||
|
||||
scope->RemoveWrappedNativeProtos();
|
||||
|
||||
if (!nsXPCComponents::AttachNewComponentsObject(ccx, scope, aGlobalJSObj))
|
||||
if (!nsXPCComponents::AttachComponentsObject(ccx, scope, aGlobalJSObj))
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
|
||||
if (XPCPerThreadData::IsMainThread(ccx)) {
|
||||
|
@ -1222,7 +1222,7 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
|||
|
||||
if (!(aFlags & nsIXPConnect::OMIT_COMPONENTS_OBJECT)) {
|
||||
// XPCCallContext gives us an active request needed to save/restore.
|
||||
if (!nsXPCComponents::AttachNewComponentsObject(ccx, wrappedGlobal->GetScope(), global))
|
||||
if (!nsXPCComponents::AttachComponentsObject(ccx, wrappedGlobal->GetScope(), global))
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
|
||||
if (XPCPerThreadData::IsMainThread(ccx)) {
|
||||
|
|
|
@ -3888,9 +3888,9 @@ public:
|
|||
|
||||
public:
|
||||
static JSBool
|
||||
AttachNewComponentsObject(XPCCallContext& ccx,
|
||||
XPCWrappedNativeScope* aScope,
|
||||
JSObject* aGlobal);
|
||||
AttachComponentsObject(XPCCallContext& ccx,
|
||||
XPCWrappedNativeScope* aScope,
|
||||
JSObject* aGlobal);
|
||||
|
||||
void SystemIsBeingShutDown() {ClearMembers();}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче