зеркало из https://github.com/mozilla/pjs.git
Bug 698382 - Give nsXBLProtoImpl::InitTargetObjects and nsXBLPrototypeBinding::InitClass a JSObject outparam; r=jst
This commit is contained in:
Родитель
6c69b149be
Коммит
064b072294
|
@ -1208,19 +1208,17 @@ nsresult
|
||||||
nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||||
const nsAFlatCString& aClassName,
|
const nsAFlatCString& aClassName,
|
||||||
nsXBLPrototypeBinding* aProtoBinding,
|
nsXBLPrototypeBinding* aProtoBinding,
|
||||||
void **aClassObject)
|
JSObject** aClassObject)
|
||||||
{
|
{
|
||||||
// First ensure our JS class is initialized.
|
// First ensure our JS class is initialized.
|
||||||
jsval val;
|
|
||||||
JSObject* proto = NULL;
|
|
||||||
|
|
||||||
nsCAutoString className(aClassName);
|
nsCAutoString className(aClassName);
|
||||||
JSObject* parent_proto = nsnull; // If we have an "obj" we can set this
|
JSObject* parent_proto = nsnull; // If we have an "obj" we can set this
|
||||||
JSAutoRequest ar(cx);
|
JSAutoRequest ar(cx);
|
||||||
|
|
||||||
JSAutoEnterCompartment ac;
|
JSAutoEnterCompartment ac;
|
||||||
if (!ac.enter(cx, global))
|
if (!ac.enter(cx, global)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
// Retrieve the current prototype of obj.
|
// Retrieve the current prototype of obj.
|
||||||
|
@ -1246,6 +1244,8 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jsval val;
|
||||||
|
JSObject* proto = NULL;
|
||||||
if ((!::JS_LookupPropertyWithFlags(cx, global, className.get(),
|
if ((!::JS_LookupPropertyWithFlags(cx, global, className.get(),
|
||||||
JSRESOLVE_CLASSNAME,
|
JSRESOLVE_CLASSNAME,
|
||||||
&val)) ||
|
&val)) ||
|
||||||
|
@ -1336,7 +1336,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
*aClassObject = (void*)proto;
|
*aClassObject = proto;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
proto = JSVAL_TO_OBJECT(val);
|
proto = JSVAL_TO_OBJECT(val);
|
||||||
|
|
|
@ -146,7 +146,7 @@ public:
|
||||||
static nsresult DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
static nsresult DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||||
const nsAFlatCString& aClassName,
|
const nsAFlatCString& aClassName,
|
||||||
nsXBLPrototypeBinding* aProtoBinding,
|
nsXBLPrototypeBinding* aProtoBinding,
|
||||||
void **aClassObject);
|
JSObject** aClassObject);
|
||||||
|
|
||||||
bool AllowScripts(); // XXX make const
|
bool AllowScripts(); // XXX make const
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ nsXBLProtoImpl::InstallImplementation(nsXBLPrototypeBinding* aBinding, nsIConten
|
||||||
// This function also has the side effect of building up the prototype implementation if it has
|
// This function also has the side effect of building up the prototype implementation if it has
|
||||||
// not been built already.
|
// not been built already.
|
||||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||||
void * targetClassObject = nsnull;
|
JSObject* targetClassObject = nsnull;
|
||||||
nsresult rv = InitTargetObjects(aBinding, context, aBoundElement,
|
nsresult rv = InitTargetObjects(aBinding, context, aBoundElement,
|
||||||
getter_AddRefs(holder), &targetClassObject);
|
getter_AddRefs(holder), &targetClassObject);
|
||||||
NS_ENSURE_SUCCESS(rv, rv); // kick out if we were unable to properly intialize our target objects
|
NS_ENSURE_SUCCESS(rv, rv); // kick out if we were unable to properly intialize our target objects
|
||||||
|
@ -122,7 +122,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
||||||
nsIScriptContext* aContext,
|
nsIScriptContext* aContext,
|
||||||
nsIContent* aBoundElement,
|
nsIContent* aBoundElement,
|
||||||
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
||||||
void** aTargetClassObject)
|
JSObject** aTargetClassObject)
|
||||||
{
|
{
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
*aScriptObjectHolder = nsnull;
|
*aScriptObjectHolder = nsnull;
|
||||||
|
@ -161,8 +161,9 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
||||||
// object's old base class becomes the new class' base class.
|
// object's old base class becomes the new class' base class.
|
||||||
rv = aBinding->InitClass(mClassName, jscontext, global, JSVAL_TO_OBJECT(v),
|
rv = aBinding->InitClass(mClassName, jscontext, global, JSVAL_TO_OBJECT(v),
|
||||||
aTargetClassObject);
|
aTargetClassObject);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv)) {
|
||||||
return rv;
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
nsContentUtils::PreserveWrapper(aBoundElement, aBoundElement);
|
nsContentUtils::PreserveWrapper(aBoundElement, aBoundElement);
|
||||||
|
|
||||||
|
@ -189,13 +190,13 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
|
||||||
JSObject *global = globalObject->GetGlobalJSObject();
|
JSObject *global = globalObject->GetGlobalJSObject();
|
||||||
|
|
||||||
|
|
||||||
void* classObject;
|
JSObject* classObject;
|
||||||
nsresult rv = aBinding->InitClass(mClassName, cx, global, global,
|
nsresult rv = aBinding->InitClass(mClassName, cx, global, global,
|
||||||
&classObject);
|
&classObject);
|
||||||
if (NS_FAILED(rv))
|
if (NS_FAILED(rv))
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
mClassObject = (JSObject*) classObject;
|
mClassObject = classObject;
|
||||||
if (!mClassObject)
|
if (!mClassObject)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
@ -310,12 +311,12 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
||||||
JSContext *cx = aContext->GetNativeContext();
|
JSContext *cx = aContext->GetNativeContext();
|
||||||
JSObject *global = aGlobal->GetGlobalJSObject();
|
JSObject *global = aGlobal->GetGlobalJSObject();
|
||||||
|
|
||||||
void* classObject;
|
JSObject* classObject;
|
||||||
nsresult rv = aBinding->InitClass(mClassName, cx, global, global, &classObject);
|
nsresult rv = aBinding->InitClass(mClassName, cx, global, global, &classObject);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
NS_ENSURE_TRUE(classObject, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(classObject, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
mClassObject = (JSObject*) classObject;
|
mClassObject = classObject;
|
||||||
|
|
||||||
nsXBLProtoImplField* previousField = nsnull;
|
nsXBLProtoImplField* previousField = nsnull;
|
||||||
nsXBLProtoImplMember* previousMember = nsnull;
|
nsXBLProtoImplMember* previousMember = nsnull;
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext,
|
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext,
|
||||||
nsIContent* aBoundElement,
|
nsIContent* aBoundElement,
|
||||||
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
||||||
void** aTargetClassObject);
|
JSObject** aTargetClassObject);
|
||||||
nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
|
nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
|
||||||
|
|
||||||
void SetMemberList(nsXBLProtoImplMember* aMemberList)
|
void SetMemberList(nsXBLProtoImplMember* aMemberList)
|
||||||
|
|
|
@ -868,7 +868,7 @@ nsresult
|
||||||
nsXBLPrototypeBinding::InitClass(const nsCString& aClassName,
|
nsXBLPrototypeBinding::InitClass(const nsCString& aClassName,
|
||||||
JSContext * aContext, JSObject * aGlobal,
|
JSContext * aContext, JSObject * aGlobal,
|
||||||
JSObject * aScriptObject,
|
JSObject * aScriptObject,
|
||||||
void ** aClassObject)
|
JSObject** aClassObject)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aClassObject);
|
NS_ENSURE_ARG_POINTER(aClassObject);
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ public:
|
||||||
|
|
||||||
nsresult InitClass(const nsCString& aClassName, JSContext * aContext,
|
nsresult InitClass(const nsCString& aClassName, JSContext * aContext,
|
||||||
JSObject * aGlobal, JSObject * aScriptObject,
|
JSObject * aGlobal, JSObject * aScriptObject,
|
||||||
void ** aClassObject);
|
JSObject** aClassObject);
|
||||||
|
|
||||||
nsresult ConstructInterfaceTable(const nsAString& aImpls);
|
nsresult ConstructInterfaceTable(const nsAString& aImpls);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче