зеркало из 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,
|
||||
const nsAFlatCString& aClassName,
|
||||
nsXBLPrototypeBinding* aProtoBinding,
|
||||
void **aClassObject)
|
||||
JSObject** aClassObject)
|
||||
{
|
||||
// First ensure our JS class is initialized.
|
||||
jsval val;
|
||||
JSObject* proto = NULL;
|
||||
|
||||
nsCAutoString className(aClassName);
|
||||
JSObject* parent_proto = nsnull; // If we have an "obj" we can set this
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, global))
|
||||
if (!ac.enter(cx, global)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (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(),
|
||||
JSRESOLVE_CLASSNAME,
|
||||
&val)) ||
|
||||
|
@ -1336,7 +1336,7 @@ nsXBLBinding::DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
*aClassObject = (void*)proto;
|
||||
*aClassObject = proto;
|
||||
}
|
||||
else {
|
||||
proto = JSVAL_TO_OBJECT(val);
|
||||
|
|
|
@ -146,7 +146,7 @@ public:
|
|||
static nsresult DoInitJSClass(JSContext *cx, JSObject *global, JSObject *obj,
|
||||
const nsAFlatCString& aClassName,
|
||||
nsXBLPrototypeBinding* aProtoBinding,
|
||||
void **aClassObject);
|
||||
JSObject** aClassObject);
|
||||
|
||||
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
|
||||
// not been built already.
|
||||
nsCOMPtr<nsIXPConnectJSObjectHolder> holder;
|
||||
void * targetClassObject = nsnull;
|
||||
JSObject* targetClassObject = nsnull;
|
||||
nsresult rv = InitTargetObjects(aBinding, context, aBoundElement,
|
||||
getter_AddRefs(holder), &targetClassObject);
|
||||
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,
|
||||
nsIContent* aBoundElement,
|
||||
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
||||
void** aTargetClassObject)
|
||||
JSObject** aTargetClassObject)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
*aScriptObjectHolder = nsnull;
|
||||
|
@ -161,8 +161,9 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
|
|||
// object's old base class becomes the new class' base class.
|
||||
rv = aBinding->InitClass(mClassName, jscontext, global, JSVAL_TO_OBJECT(v),
|
||||
aTargetClassObject);
|
||||
if (NS_FAILED(rv))
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsContentUtils::PreserveWrapper(aBoundElement, aBoundElement);
|
||||
|
||||
|
@ -189,13 +190,13 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
|
|||
JSObject *global = globalObject->GetGlobalJSObject();
|
||||
|
||||
|
||||
void* classObject;
|
||||
JSObject* classObject;
|
||||
nsresult rv = aBinding->InitClass(mClassName, cx, global, global,
|
||||
&classObject);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mClassObject = (JSObject*) classObject;
|
||||
mClassObject = classObject;
|
||||
if (!mClassObject)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
@ -310,12 +311,12 @@ nsXBLProtoImpl::Read(nsIScriptContext* aContext,
|
|||
JSContext *cx = aContext->GetNativeContext();
|
||||
JSObject *global = aGlobal->GetGlobalJSObject();
|
||||
|
||||
void* classObject;
|
||||
JSObject* classObject;
|
||||
nsresult rv = aBinding->InitClass(mClassName, cx, global, global, &classObject);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(classObject, NS_ERROR_FAILURE);
|
||||
|
||||
mClassObject = (JSObject*) classObject;
|
||||
mClassObject = classObject;
|
||||
|
||||
nsXBLProtoImplField* previousField = nsnull;
|
||||
nsXBLProtoImplMember* previousMember = nsnull;
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
|
||||
void** aTargetClassObject);
|
||||
JSObject** aTargetClassObject);
|
||||
nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
|
||||
|
||||
void SetMemberList(nsXBLProtoImplMember* aMemberList)
|
||||
|
|
|
@ -868,7 +868,7 @@ nsresult
|
|||
nsXBLPrototypeBinding::InitClass(const nsCString& aClassName,
|
||||
JSContext * aContext, JSObject * aGlobal,
|
||||
JSObject * aScriptObject,
|
||||
void ** aClassObject)
|
||||
JSObject** aClassObject)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aClassObject);
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ public:
|
|||
|
||||
nsresult InitClass(const nsCString& aClassName, JSContext * aContext,
|
||||
JSObject * aGlobal, JSObject * aScriptObject,
|
||||
void ** aClassObject);
|
||||
JSObject** aClassObject);
|
||||
|
||||
nsresult ConstructInterfaceTable(const nsAString& aImpls);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче