mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 14:55:47 +00:00
Bug 959787 - Handlify JS_Delete* APIs r=sfink
This commit is contained in:
parent
eddc75fd8f
commit
d10337280e
@ -2546,7 +2546,8 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument,
|
||||
// make sure the cached document property gets updated.
|
||||
|
||||
// XXXmarkh - tell other languages about this?
|
||||
::JS_DeleteProperty(cx, currentInner->mJSObject, "document");
|
||||
JS::Rooted<JSObject*> obj(cx, currentInner->mJSObject);
|
||||
::JS_DeleteProperty(cx, obj, "document");
|
||||
}
|
||||
} else {
|
||||
newInnerWindow->InnerSetNewDocument(aDocument);
|
||||
|
@ -810,7 +810,7 @@ nsJSObjWrapper::NP_SetProperty(NPObject *npobj, NPIdentifier id,
|
||||
|
||||
// static
|
||||
bool
|
||||
nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier id)
|
||||
nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier npid)
|
||||
{
|
||||
NPP npp = NPPStack::Peek();
|
||||
JSContext *cx = GetJSContext(npp);
|
||||
@ -833,17 +833,19 @@ nsJSObjWrapper::NP_RemoveProperty(NPObject *npobj, NPIdentifier id)
|
||||
pusher.Push(cx);
|
||||
AutoJSExceptionReporter reporter(cx);
|
||||
bool deleted = false;
|
||||
JSAutoCompartment ac(cx, npjsobj->mJSObj);
|
||||
JS::Rooted<JSObject*> obj(cx, npjsobj->mJSObj);
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
|
||||
NS_ASSERTION(NPIdentifierIsInt(id) || NPIdentifierIsString(id),
|
||||
NS_ASSERTION(NPIdentifierIsInt(npid) || NPIdentifierIsString(npid),
|
||||
"id must be either string or int!\n");
|
||||
ok = ::JS_DeletePropertyById2(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), &deleted);
|
||||
JS::Rooted<jsid> id(cx, NPIdentifierToJSId(npid));
|
||||
ok = ::JS_DeletePropertyById2(cx, obj, id, &deleted);
|
||||
if (ok && deleted) {
|
||||
// FIXME: See bug 425823, we shouldn't need to do this, and once
|
||||
// that bug is fixed we can remove this code.
|
||||
|
||||
bool hasProp;
|
||||
ok = ::JS_HasPropertyById(cx, npjsobj->mJSObj, NPIdentifierToJSId(id), &hasProp);
|
||||
ok = ::JS_HasPropertyById(cx, obj, id, &hasProp);
|
||||
|
||||
if (ok && hasProp) {
|
||||
// The property might have been deleted, but it got
|
||||
|
@ -3457,9 +3457,8 @@ JS_SetUCProperty(JSContext *cx, JSObject *objArg, const jschar *name, size_t nam
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DeletePropertyById2(JSContext *cx, JSObject *objArg, jsid id, bool *result)
|
||||
JS_DeletePropertyById2(JSContext *cx, HandleObject obj, HandleId id, bool *result)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj, id);
|
||||
@ -3473,9 +3472,8 @@ JS_DeletePropertyById2(JSContext *cx, JSObject *objArg, jsid id, bool *result)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DeleteElement2(JSContext *cx, JSObject *objArg, uint32_t index, bool *result)
|
||||
JS_DeleteElement2(JSContext *cx, HandleObject obj, uint32_t index, bool *result)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
@ -3485,9 +3483,8 @@ JS_DeleteElement2(JSContext *cx, JSObject *objArg, uint32_t index, bool *result)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DeleteProperty2(JSContext *cx, JSObject *objArg, const char *name, bool *result)
|
||||
JS_DeleteProperty2(JSContext *cx, HandleObject obj, const char *name, bool *result)
|
||||
{
|
||||
RootedObject obj(cx, objArg);
|
||||
CHECK_REQUEST(cx);
|
||||
assertSameCompartment(cx, obj);
|
||||
JSAutoResolveFlags rf(cx, 0);
|
||||
@ -3514,24 +3511,24 @@ JS_DeleteUCProperty2(JSContext *cx, JSObject *objArg, const jschar *name, size_t
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DeletePropertyById(JSContext *cx, JSObject *objArg, jsid idArg)
|
||||
JS_DeletePropertyById(JSContext *cx, HandleObject obj, HandleId id)
|
||||
{
|
||||
bool junk;
|
||||
return JS_DeletePropertyById2(cx, objArg, idArg, &junk);
|
||||
return JS_DeletePropertyById2(cx, obj, id, &junk);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DeleteElement(JSContext *cx, JSObject *objArg, uint32_t index)
|
||||
JS_DeleteElement(JSContext *cx, HandleObject obj, uint32_t index)
|
||||
{
|
||||
bool junk;
|
||||
return JS_DeleteElement2(cx, objArg, index, &junk);
|
||||
return JS_DeleteElement2(cx, obj, index, &junk);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_DeleteProperty(JSContext *cx, JSObject *objArg, const char *name)
|
||||
JS_DeleteProperty(JSContext *cx, HandleObject obj, const char *name)
|
||||
{
|
||||
bool junk;
|
||||
return JS_DeleteProperty2(cx, objArg, name, &junk);
|
||||
return JS_DeleteProperty2(cx, obj, name, &junk);
|
||||
}
|
||||
|
||||
static Shape *
|
||||
|
@ -3001,16 +3001,16 @@ extern JS_PUBLIC_API(bool)
|
||||
JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, JS::HandleValue v);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name);
|
||||
JS_DeleteProperty(JSContext *cx, JS::HandleObject obj, const char *name);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name, bool *succeeded);
|
||||
JS_DeleteProperty2(JSContext *cx, JS::HandleObject obj, const char *name, bool *succeeded);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id);
|
||||
JS_DeletePropertyById(JSContext *cx, JS::HandleObject obj, jsid id);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, bool *succeeded);
|
||||
JS_DeletePropertyById2(JSContext *cx, JS::HandleObject obj, JS::HandleId id, bool *succeeded);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DefineUCProperty(JSContext *cx, JSObject *obj,
|
||||
@ -3089,10 +3089,10 @@ extern JS_PUBLIC_API(bool)
|
||||
JS_SetElement(JSContext *cx, JSObject *obj, uint32_t index, JS::MutableHandleValue vp);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DeleteElement(JSContext *cx, JSObject *obj, uint32_t index);
|
||||
JS_DeleteElement(JSContext *cx, JS::HandleObject obj, uint32_t index);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_DeleteElement2(JSContext *cx, JSObject *obj, uint32_t index, bool *succeeded);
|
||||
JS_DeleteElement2(JSContext *cx, JS::HandleObject obj, uint32_t index, bool *succeeded);
|
||||
|
||||
/*
|
||||
* Remove all configurable properties from the given (non-global) object and
|
||||
|
Loading…
Reference in New Issue
Block a user