Bug 855411 - Root various things. r=bz,terrence

This commit is contained in:
Tom Schuster 2013-04-05 15:21:03 +02:00
parent d3ebb2d912
commit ec87b7de30
5 changed files with 16 additions and 20 deletions

View File

@ -794,7 +794,7 @@ nsXBLBinding::InstallImplementation()
nsresult rv = mNextBinding->InstallImplementation();
NS_ENSURE_SUCCESS(rv, rv);
}
// iterate through each property in the prototype's list and install the property.
if (AllowScripts())
return mPrototypeBinding->InstallImplementation(this);
@ -1397,7 +1397,7 @@ nsXBLBinding::GetFirstStyleBinding()
}
bool
nsXBLBinding::ResolveAllFields(JSContext *cx, JSObject *obj) const
nsXBLBinding::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
{
if (!mPrototypeBinding->ResolveAllFields(cx, obj)) {
return false;

View File

@ -118,7 +118,7 @@ public:
// Resolve all the fields for this binding and all ancestor bindings on the
// object |obj|. False return means a JS exception was set.
bool ResolveAllFields(JSContext *cx, JSObject *obj) const;
bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const;
// Get the list of insertion points for aParent. The nsInsertionPointList
// is owned by the binding, you should not delete it.

View File

@ -147,7 +147,7 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
nsIScriptContext* aContext,
nsIContent* aBoundElement,
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
JSObject** aTargetClassObject,
JS::MutableHandle<JSObject*> aTargetClassObject,
bool* aTargetIsNew)
{
nsresult rv = NS_OK;
@ -181,20 +181,16 @@ nsXBLProtoImpl::InitTargetObjects(nsXBLPrototypeBinding* aBinding,
NS_ENSURE_SUCCESS(rv, rv);
JS::Rooted<JSObject*> value(cx, &v.toObject());
JS::Rooted<JSObject*> targetClassObject(cx, *aTargetClassObject);
// All of the above code was just obtaining the bound element's script object and its immediate
// concrete base class. We need to alter the object so that our concrete class is interposed
// between the object and its base class. We become the new base class of the object, and the
// object's old base class becomes the new class' base class.
rv = aBinding->InitClass(mClassName, cx, global, value,
&targetClassObject, aTargetIsNew);
rv = aBinding->InitClass(mClassName, cx, global, value, aTargetClassObject, aTargetIsNew);
if (NS_FAILED(rv)) {
return rv;
}
*aTargetClassObject = targetClassObject;
nsContentUtils::PreserveWrapper(aBoundElement, aBoundElement);
wrapper.swap(*aScriptObjectHolder);
@ -299,7 +295,7 @@ nsXBLProtoImpl::FindField(const nsString& aFieldName) const
}
bool
nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JSObject *obj) const
nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const
{
AutoVersionChecker avc(cx);
for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
@ -307,10 +303,10 @@ nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JSObject *obj) const
// PRUnichar* for the property name. Let's just use the public API and
// all.
nsDependentString name(f->GetName());
JS::Value dummy;
JS::Rooted<JS::Value> dummy(cx);
if (!::JS_LookupUCProperty(cx, obj,
reinterpret_cast<const jschar*>(name.get()),
name.Length(), &dummy)) {
name.Length(), dummy.address())) {
return false;
}
}
@ -319,7 +315,7 @@ nsXBLProtoImpl::ResolveAllFields(JSContext *cx, JSObject *obj) const
}
void
nsXBLProtoImpl::UndefineFields(JSContext *cx, JSObject *obj) const
nsXBLProtoImpl::UndefineFields(JSContext *cx, JS::Handle<JSObject*> obj) const
{
JSAutoRequest ar(cx);
for (nsXBLProtoImplField* f = mFields; f; f = f->GetNext()) {
@ -329,8 +325,8 @@ nsXBLProtoImpl::UndefineFields(JSContext *cx, JSObject *obj) const
JSBool hasProp;
if (::JS_AlreadyHasOwnUCProperty(cx, obj, s, name.Length(), &hasProp) &&
hasProp) {
JS::Value dummy;
::JS_DeleteUCProperty2(cx, obj, s, name.Length(), &dummy);
JS::Rooted<JS::Value> dummy(cx);
::JS_DeleteUCProperty2(cx, obj, s, name.Length(), dummy.address());
}
}
}

View File

@ -41,7 +41,7 @@ public:
nsresult InitTargetObjects(nsXBLPrototypeBinding* aBinding, nsIScriptContext* aContext,
nsIContent* aBoundElement,
nsIXPConnectJSObjectHolder** aScriptObjectHolder,
JSObject** aTargetClassObject,
JS::MutableHandle<JSObject*> aTargetClassObject,
bool* aTargetIsNew);
nsresult CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding);
@ -67,11 +67,11 @@ public:
// Resolve all the fields for this implementation on the object |obj| False
// return means a JS exception was set.
bool ResolveAllFields(JSContext *cx, JSObject *obj) const;
bool ResolveAllFields(JSContext *cx, JS::Handle<JSObject*> obj) const;
// Undefine all our fields from object |obj| (which should be a
// JSObject for a bound element).
void UndefineFields(JSContext* cx, JSObject* obj) const;
void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const;
bool CompiledMembers() const {
return mClassObject != nullptr;

View File

@ -101,14 +101,14 @@ public:
// Resolve all the fields for this binding on the object |obj|.
// False return means a JS exception was set.
bool ResolveAllFields(JSContext* cx, JSObject* obj) const
bool ResolveAllFields(JSContext* cx, JS::Handle<JSObject*> obj) const
{
return !mImplementation || mImplementation->ResolveAllFields(cx, obj);
}
// Undefine all our fields from object |obj| (which should be a
// JSObject for a bound element).
void UndefineFields(JSContext* cx, JSObject* obj) const {
void UndefineFields(JSContext* cx, JS::Handle<JSObject*> obj) const {
if (mImplementation) {
mImplementation->UndefineFields(cx, obj);
}