зеркало из https://github.com/mozilla/pjs.git
Bug 745478 - Pass JSObjects to nsXBLProtoImplMember::InstallMember; r=jst
This commit is contained in:
Родитель
221ef4cce0
Коммит
3cbdeba8de
|
@ -110,8 +110,8 @@ public:
|
|||
|
||||
virtual nsresult InstallMember(nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
void* aScriptObject,
|
||||
void* aTargetClassObject,
|
||||
JSObject* aScriptObject, // Unused
|
||||
JSObject* aTargetClassObject,
|
||||
const nsCString& aClassStr) = 0;
|
||||
virtual nsresult CompileMember(nsIScriptContext* aContext,
|
||||
const nsCString& aClassStr,
|
||||
|
|
|
@ -122,31 +122,28 @@ nsXBLProtoImplMethod::SetLineNumber(PRUint32 aLineNumber)
|
|||
nsresult
|
||||
nsXBLProtoImplMethod::InstallMember(nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
void* aScriptObject,
|
||||
void* aTargetClassObject,
|
||||
JSObject* aScriptObject,
|
||||
JSObject* aTargetClassObject,
|
||||
const nsCString& aClassStr)
|
||||
{
|
||||
NS_PRECONDITION(IsCompiled(),
|
||||
"Should not be installing an uncompiled method");
|
||||
JSContext* cx = aContext->GetNativeContext();
|
||||
|
||||
nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
|
||||
nsIScriptGlobalObject *sgo;
|
||||
nsIScriptGlobalObject* sgo = aBoundElement->OwnerDoc()->GetScopeObject();
|
||||
|
||||
if (!(sgo = ownerDoc->GetScopeObject())) {
|
||||
if (!sgo) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JSObject * scriptObject = (JSObject *) aScriptObject;
|
||||
NS_ASSERTION(scriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
|
||||
if (!scriptObject)
|
||||
NS_ASSERTION(aScriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
|
||||
if (!aScriptObject)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSObject * targetClassObject = (JSObject *) aTargetClassObject;
|
||||
JSObject* globalObject = sgo->GetGlobalJSObject();
|
||||
|
||||
// now we want to reevaluate our property using aContext and the script object for this window...
|
||||
if (mJSMethodObject && targetClassObject) {
|
||||
if (mJSMethodObject && aTargetClassObject) {
|
||||
nsDependentString name(mName);
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoEnterCompartment ac;
|
||||
|
@ -160,8 +157,8 @@ nsXBLProtoImplMethod::InstallMember(nsIScriptContext* aContext,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (!::JS_DefineUCProperty(cx, targetClassObject,
|
||||
reinterpret_cast<const jschar*>(mName),
|
||||
if (!::JS_DefineUCProperty(cx, aTargetClassObject,
|
||||
static_cast<const jschar*>(mName),
|
||||
name.Length(), OBJECT_TO_JSVAL(method),
|
||||
NULL, NULL, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
|
|
@ -122,8 +122,8 @@ public:
|
|||
|
||||
virtual nsresult InstallMember(nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
void* aScriptObject,
|
||||
void* aTargetClassObject,
|
||||
JSObject* aScriptObject,
|
||||
JSObject* aTargetClassObject,
|
||||
const nsCString& aClassStr);
|
||||
virtual nsresult CompileMember(nsIScriptContext* aContext,
|
||||
const nsCString& aClassStr,
|
||||
|
@ -174,8 +174,8 @@ public:
|
|||
// prototype implementation).
|
||||
virtual nsresult InstallMember(nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
void* aScriptObject,
|
||||
void* aTargetClassObject,
|
||||
JSObject* aScriptObject,
|
||||
JSObject* aTargetClassObject,
|
||||
const nsCString& aClassStr) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -166,31 +166,28 @@ const char* gPropertyArgs[] = { "val" };
|
|||
nsresult
|
||||
nsXBLProtoImplProperty::InstallMember(nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
void* aScriptObject,
|
||||
void* aTargetClassObject,
|
||||
JSObject* aScriptObject,
|
||||
JSObject* aTargetClassObject,
|
||||
const nsCString& aClassStr)
|
||||
{
|
||||
NS_PRECONDITION(mIsCompiled,
|
||||
"Should not be installing an uncompiled property");
|
||||
JSContext* cx = aContext->GetNativeContext();
|
||||
|
||||
nsIDocument *ownerDoc = aBoundElement->OwnerDoc();
|
||||
nsIScriptGlobalObject *sgo;
|
||||
nsIScriptGlobalObject* sgo = aBoundElement->OwnerDoc()->GetScopeObject();
|
||||
|
||||
if (!(sgo = ownerDoc->GetScopeObject())) {
|
||||
if (!sgo) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
JSObject * scriptObject = (JSObject *) aScriptObject;
|
||||
NS_ASSERTION(scriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
|
||||
if (!scriptObject)
|
||||
NS_ASSERTION(aScriptObject, "uh-oh, script Object should NOT be null or bad things will happen");
|
||||
if (!aScriptObject)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
JSObject * targetClassObject = (JSObject *) aTargetClassObject;
|
||||
JSObject * globalObject = sgo->GetGlobalJSObject();
|
||||
|
||||
// now we want to reevaluate our property using aContext and the script object for this window...
|
||||
if ((mJSGetterObject || mJSSetterObject) && targetClassObject) {
|
||||
if ((mJSGetterObject || mJSSetterObject) && aTargetClassObject) {
|
||||
JSObject * getter = nsnull;
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoEnterCompartment ac;
|
||||
|
@ -208,8 +205,8 @@ nsXBLProtoImplProperty::InstallMember(nsIScriptContext* aContext,
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsDependentString name(mName);
|
||||
if (!::JS_DefineUCProperty(cx, targetClassObject,
|
||||
reinterpret_cast<const jschar*>(mName),
|
||||
if (!::JS_DefineUCProperty(cx, aTargetClassObject,
|
||||
static_cast<const jschar*>(mName),
|
||||
name.Length(), JSVAL_VOID,
|
||||
JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter),
|
||||
JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter),
|
||||
|
|
|
@ -67,8 +67,8 @@ public:
|
|||
|
||||
virtual nsresult InstallMember(nsIScriptContext* aContext,
|
||||
nsIContent* aBoundElement,
|
||||
void* aScriptObject,
|
||||
void* aTargetClassObject,
|
||||
JSObject* aScriptObject,
|
||||
JSObject* aTargetClassObject,
|
||||
const nsCString& aClassStr);
|
||||
virtual nsresult CompileMember(nsIScriptContext* aContext,
|
||||
const nsCString& aClassStr,
|
||||
|
|
Загрузка…
Ссылка в новой задаче