mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 645416, part 22 - Remove JSCompartment::wrapId. r=terrence.
This is unnecessary now that object jsids no longer exist. Both string and symbol jsids point only to GC things in the atoms compartment, which are safe to pass to any compartment without wrapping. --HG-- extra : rebase_source : 82c21e8474df05b1bb42c14d872c981205bbe879
This commit is contained in:
parent
00dd69c3f8
commit
30f843bf05
@ -1128,9 +1128,7 @@ nsXBLBinding::LookupMember(JSContext* aCx, JS::Handle<jsid> aId,
|
||||
{
|
||||
JSAutoCompartment ac(aCx, xblScope);
|
||||
JS::Rooted<jsid> id(aCx, aId);
|
||||
if (!JS_WrapId(aCx, &id) ||
|
||||
!LookupMemberInternal(aCx, name, id, aDesc, xblScope))
|
||||
{
|
||||
if (!LookupMemberInternal(aCx, name, id, aDesc, xblScope)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx,
|
||||
// First, enter the XBL scope, and compile the functions there.
|
||||
JSAutoCompartment ac(aCx, scopeObject);
|
||||
JS::Rooted<JS::Value> wrappedClassObj(aCx, JS::ObjectValue(*aTargetClassObject));
|
||||
if (!JS_WrapValue(aCx, &wrappedClassObj) || !JS_WrapId(aCx, &id))
|
||||
if (!JS_WrapValue(aCx, &wrappedClassObj))
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
JS::Rooted<JSObject*> get(aCx,
|
||||
@ -359,9 +359,7 @@ nsXBLProtoImplField::InstallAccessors(JSContext* aCx,
|
||||
// Now, re-enter the class object's scope, wrap the getters/setters, and define
|
||||
// them there.
|
||||
JSAutoCompartment ac2(aCx, aTargetClassObject);
|
||||
if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set) ||
|
||||
!JS_WrapId(aCx, &id))
|
||||
{
|
||||
if (!JS_WrapObject(aCx, &get) || !JS_WrapObject(aCx, &set)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -513,8 +513,6 @@ jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* nameStr)
|
||||
JSAutoCompartment ac(cx, obj);
|
||||
JS::RootedId id(cx, nameid);
|
||||
|
||||
if(!JS_WrapId(cx, &id))
|
||||
return nullptr;
|
||||
if(!JS_GetOwnPropertyDescriptorById(cx, obj, id, &desc))
|
||||
return nullptr;
|
||||
if(!desc.object())
|
||||
|
@ -1069,19 +1069,6 @@ JS_WrapValue(JSContext *cx, MutableHandleValue vp)
|
||||
return cx->compartment()->wrap(cx, vp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS_WrapId(JSContext *cx, JS::MutableHandleId idp)
|
||||
{
|
||||
AssertHeapIsIdle(cx);
|
||||
CHECK_REQUEST(cx);
|
||||
jsid id = idp.get();
|
||||
if (JSID_IS_STRING(id))
|
||||
JS::ExposeGCThingToActiveJS(JSID_TO_STRING(id), JSTRACE_STRING);
|
||||
else if (JSID_IS_SYMBOL(id))
|
||||
JS::ExposeGCThingToActiveJS(JSID_TO_STRING(id), JSTRACE_STRING);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Identity remapping. Not for casual consumers.
|
||||
*
|
||||
|
@ -1648,9 +1648,6 @@ JS_WrapObject(JSContext *cx, JS::MutableHandleObject objp);
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_WrapValue(JSContext *cx, JS::MutableHandleValue vp);
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
JS_WrapId(JSContext *cx, JS::MutableHandleId idp);
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_TransplantObject(JSContext *cx, JS::HandleObject origobj, JS::HandleObject target);
|
||||
|
||||
|
@ -460,23 +460,6 @@ JSCompartment::wrap(JSContext *cx, MutableHandleObject obj, HandleObject existin
|
||||
return putWrapper(cx, CrossCompartmentKey(key), ObjectValue(*obj));
|
||||
}
|
||||
|
||||
bool
|
||||
JSCompartment::wrapId(JSContext *cx, jsid *idp)
|
||||
{
|
||||
MOZ_ASSERT(*idp != JSID_VOID, "JSID_VOID is an out-of-band sentinel value");
|
||||
if (JSID_IS_INT(*idp))
|
||||
return true;
|
||||
RootedValue value(cx, IdToValue(*idp));
|
||||
if (!wrap(cx, &value))
|
||||
return false;
|
||||
RootedId id(cx);
|
||||
if (!ValueToId<CanGC>(cx, value, &id))
|
||||
return false;
|
||||
|
||||
*idp = id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JSCompartment::wrap(JSContext *cx, PropertyOp *propp)
|
||||
{
|
||||
@ -515,18 +498,6 @@ JSCompartment::wrap(JSContext *cx, MutableHandle<PropertyDescriptor> desc)
|
||||
return wrap(cx, desc.value());
|
||||
}
|
||||
|
||||
bool
|
||||
JSCompartment::wrap(JSContext *cx, AutoIdVector &props)
|
||||
{
|
||||
jsid *vector = props.begin();
|
||||
int length = props.length();
|
||||
for (size_t n = 0; n < size_t(length); ++n) {
|
||||
if (!wrapId(cx, &vector[n]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
JSCompartment::wrap(JSContext *cx, MutableHandle<PropDesc> desc)
|
||||
{
|
||||
|
@ -317,11 +317,9 @@ struct JSCompartment
|
||||
bool wrap(JSContext *cx, js::HeapPtrString *strp);
|
||||
bool wrap(JSContext *cx, JS::MutableHandleObject obj,
|
||||
JS::HandleObject existingArg = js::NullPtr());
|
||||
bool wrapId(JSContext *cx, jsid *idp);
|
||||
bool wrap(JSContext *cx, js::PropertyOp *op);
|
||||
bool wrap(JSContext *cx, js::StrictPropertyOp *op);
|
||||
bool wrap(JSContext *cx, JS::MutableHandle<js::PropertyDescriptor> desc);
|
||||
bool wrap(JSContext *cx, js::AutoIdVector &props);
|
||||
bool wrap(JSContext *cx, JS::MutableHandle<js::PropDesc> desc);
|
||||
|
||||
bool putWrapper(JSContext *cx, const js::CrossCompartmentKey& wrapped, const js::Value& wrapper);
|
||||
|
@ -264,12 +264,6 @@ JS_WrapPropertyDescriptor(JSContext *cx, JS::MutableHandle<js::PropertyDescripto
|
||||
return cx->compartment()->wrap(cx, desc);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(bool)
|
||||
JS_WrapAutoIdVector(JSContext *cx, js::AutoIdVector &props)
|
||||
{
|
||||
return cx->compartment()->wrap(cx, props);
|
||||
}
|
||||
|
||||
JS_FRIEND_API(void)
|
||||
JS_TraceShapeCycleCollectorChildren(JSTracer *trc, void *shape)
|
||||
{
|
||||
|
@ -1847,8 +1847,6 @@ JS_CopyPropertyFrom(JSContext *cx, HandleId id, HandleObject target,
|
||||
RootedId wrappedId(cx, id);
|
||||
if (!cx->compartment()->wrap(cx, &desc))
|
||||
return false;
|
||||
if (!cx->compartment()->wrapId(cx, wrappedId.address()))
|
||||
return false;
|
||||
|
||||
bool ignored;
|
||||
return DefineOwnProperty(cx, target, wrappedId, desc, &ignored);
|
||||
|
@ -230,10 +230,9 @@ bool
|
||||
CrossCompartmentWrapper::getPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||
Wrapper::getPropertyDescriptor(cx, wrapper, idCopy, desc),
|
||||
NOTHING,
|
||||
Wrapper::getPropertyDescriptor(cx, wrapper, id, desc),
|
||||
cx->compartment()->wrap(cx, desc));
|
||||
}
|
||||
|
||||
@ -241,10 +240,9 @@ bool
|
||||
CrossCompartmentWrapper::getOwnPropertyDescriptor(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||
Wrapper::getOwnPropertyDescriptor(cx, wrapper, idCopy, desc),
|
||||
NOTHING,
|
||||
Wrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc),
|
||||
cx->compartment()->wrap(cx, desc));
|
||||
}
|
||||
|
||||
@ -252,11 +250,10 @@ bool
|
||||
CrossCompartmentWrapper::defineProperty(JSContext *cx, HandleObject wrapper, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
Rooted<PropertyDescriptor> desc2(cx, desc);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()) && cx->compartment()->wrap(cx, &desc2),
|
||||
Wrapper::defineProperty(cx, wrapper, idCopy, &desc2),
|
||||
cx->compartment()->wrap(cx, &desc2),
|
||||
Wrapper::defineProperty(cx, wrapper, id, &desc2),
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
@ -267,16 +264,15 @@ CrossCompartmentWrapper::getOwnPropertyNames(JSContext *cx, HandleObject wrapper
|
||||
PIERCE(cx, wrapper,
|
||||
NOTHING,
|
||||
Wrapper::getOwnPropertyNames(cx, wrapper, props),
|
||||
cx->compartment()->wrap(cx, props));
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
bool
|
||||
CrossCompartmentWrapper::delete_(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||
Wrapper::delete_(cx, wrapper, idCopy, bp),
|
||||
NOTHING,
|
||||
Wrapper::delete_(cx, wrapper, id, bp),
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
@ -286,26 +282,24 @@ CrossCompartmentWrapper::enumerate(JSContext *cx, HandleObject wrapper, AutoIdVe
|
||||
PIERCE(cx, wrapper,
|
||||
NOTHING,
|
||||
Wrapper::enumerate(cx, wrapper, props),
|
||||
cx->compartment()->wrap(cx, props));
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
bool
|
||||
CrossCompartmentWrapper::has(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||
Wrapper::has(cx, wrapper, idCopy, bp),
|
||||
NOTHING,
|
||||
Wrapper::has(cx, wrapper, id, bp),
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
bool
|
||||
CrossCompartmentWrapper::hasOwn(JSContext *cx, HandleObject wrapper, HandleId id, bool *bp)
|
||||
{
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrapId(cx, idCopy.address()),
|
||||
Wrapper::hasOwn(cx, wrapper, idCopy, bp),
|
||||
NOTHING,
|
||||
Wrapper::hasOwn(cx, wrapper, id, bp),
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
@ -314,16 +308,12 @@ CrossCompartmentWrapper::get(JSContext *cx, HandleObject wrapper, HandleObject r
|
||||
HandleId id, MutableHandleValue vp)
|
||||
{
|
||||
RootedObject receiverCopy(cx, receiver);
|
||||
RootedId idCopy(cx, id);
|
||||
{
|
||||
AutoCompartment call(cx, wrappedObject(wrapper));
|
||||
if (!cx->compartment()->wrap(cx, &receiverCopy) ||
|
||||
!cx->compartment()->wrapId(cx, idCopy.address()))
|
||||
{
|
||||
if (!cx->compartment()->wrap(cx, &receiverCopy))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Wrapper::get(cx, wrapper, receiverCopy, idCopy, vp))
|
||||
if (!Wrapper::get(cx, wrapper, receiverCopy, id, vp))
|
||||
return false;
|
||||
}
|
||||
return cx->compartment()->wrap(cx, vp);
|
||||
@ -334,12 +324,10 @@ CrossCompartmentWrapper::set(JSContext *cx, HandleObject wrapper, HandleObject r
|
||||
HandleId id, bool strict, MutableHandleValue vp)
|
||||
{
|
||||
RootedObject receiverCopy(cx, receiver);
|
||||
RootedId idCopy(cx, id);
|
||||
PIERCE(cx, wrapper,
|
||||
cx->compartment()->wrap(cx, &receiverCopy) &&
|
||||
cx->compartment()->wrapId(cx, idCopy.address()) &&
|
||||
cx->compartment()->wrap(cx, vp),
|
||||
Wrapper::set(cx, wrapper, receiverCopy, idCopy, strict, vp),
|
||||
Wrapper::set(cx, wrapper, receiverCopy, id, strict, vp),
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
@ -349,7 +337,7 @@ CrossCompartmentWrapper::keys(JSContext *cx, HandleObject wrapper, AutoIdVector
|
||||
PIERCE(cx, wrapper,
|
||||
NOTHING,
|
||||
Wrapper::keys(cx, wrapper, props),
|
||||
cx->compartment()->wrap(cx, props));
|
||||
NOTHING);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -408,8 +396,6 @@ Reify(JSContext *cx, JSCompartment *origin, MutableHandleValue vp)
|
||||
if (!ValueToId<CanGC>(cx, v, &id))
|
||||
return false;
|
||||
keys.infallibleAppend(id);
|
||||
if (!origin->wrapId(cx, keys[i].address()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5248,8 +5248,6 @@ DebuggerObject_getOwnPropertyDescriptor(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
if (!cx->compartment()->wrapId(cx, id.address()))
|
||||
return false;
|
||||
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
if (!GetOwnPropertyDescriptor(cx, obj, id, &desc))
|
||||
@ -5340,8 +5338,6 @@ DebuggerObject_defineProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
if (!cx->compartment()->wrapId(cx, id.address()))
|
||||
return false;
|
||||
if (!cx->compartment()->wrap(cx, &desc))
|
||||
return false;
|
||||
if (!desc.makeObject(cx))
|
||||
@ -5385,8 +5381,6 @@ DebuggerObject_defineProperties(JSContext *cx, unsigned argc, Value *vp)
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (!cx->compartment()->wrapId(cx, ids[i].address()))
|
||||
return false;
|
||||
if (!cx->compartment()->wrap(cx, descs[i]))
|
||||
return false;
|
||||
if (descs[i].descriptorValue().isUndefined() && !descs[i].makeObject(cx))
|
||||
@ -5419,11 +5413,9 @@ DebuggerObject_deleteProperty(JSContext *cx, unsigned argc, Value *vp)
|
||||
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, obj);
|
||||
if (!cx->compartment()->wrapId(cx, id.address()))
|
||||
return false;
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
|
||||
bool succeeded;
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
if (!JSObject::deleteGeneric(cx, obj, id, &succeeded))
|
||||
return false;
|
||||
args.rval().setBoolean(succeeded);
|
||||
@ -5992,8 +5984,6 @@ DebuggerEnv_names(JSContext *cx, unsigned argc, Value *vp)
|
||||
for (size_t i = 0, len = keys.length(); i < len; i++) {
|
||||
id = keys[i];
|
||||
if (JSID_IS_ATOM(id) && IsIdentifier(JSID_TO_ATOM(id))) {
|
||||
if (!cx->compartment()->wrapId(cx, id.address()))
|
||||
return false;
|
||||
if (!NewbornArrayPush(cx, arr, StringValue(JSID_TO_STRING(id))))
|
||||
return false;
|
||||
}
|
||||
@ -6015,8 +6005,6 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
if (!cx->compartment()->wrapId(cx, id.address()))
|
||||
return false;
|
||||
|
||||
/* This can trigger resolve hooks. */
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
@ -6047,8 +6035,6 @@ DebuggerEnv_getVariable(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
if (!cx->compartment()->wrapId(cx, id.address()))
|
||||
return false;
|
||||
|
||||
/* This can trigger getters. */
|
||||
ErrorCopier ec(ac, dbg->toJSObject());
|
||||
@ -6089,7 +6075,7 @@ DebuggerEnv_setVariable(JSContext *cx, unsigned argc, Value *vp)
|
||||
{
|
||||
Maybe<AutoCompartment> ac;
|
||||
ac.construct(cx, env);
|
||||
if (!cx->compartment()->wrapId(cx, id.address()) || !cx->compartment()->wrap(cx, &v))
|
||||
if (!cx->compartment()->wrap(cx, &v))
|
||||
return false;
|
||||
|
||||
/* This can trigger setters. */
|
||||
|
@ -473,7 +473,7 @@ SilentFailure(JSContext *cx, HandleId id, const char *reason)
|
||||
bool JSXrayTraits::getOwnPropertyFromTargetIfSafe(JSContext *cx,
|
||||
HandleObject target,
|
||||
HandleObject wrapper,
|
||||
HandleId idArg,
|
||||
HandleId id,
|
||||
MutableHandle<JSPropertyDescriptor> outDesc)
|
||||
{
|
||||
// Note - This function operates in the target compartment, because it
|
||||
@ -483,9 +483,6 @@ bool JSXrayTraits::getOwnPropertyFromTargetIfSafe(JSContext *cx,
|
||||
MOZ_ASSERT(WrapperFactory::IsXrayWrapper(wrapper));
|
||||
MOZ_ASSERT(outDesc.object() == nullptr);
|
||||
|
||||
RootedId id(cx, idArg);
|
||||
if (!JS_WrapId(cx, &id))
|
||||
return false;
|
||||
Rooted<JSPropertyDescriptor> desc(cx);
|
||||
if (!JS_GetOwnPropertyDescriptorById(cx, target, id, &desc))
|
||||
return false;
|
||||
@ -842,7 +839,7 @@ JSXrayTraits::enumerateNames(JSContext *cx, HandleObject wrapper, unsigned flags
|
||||
props.infallibleAppend(id);
|
||||
}
|
||||
}
|
||||
return JS_WrapAutoIdVector(cx, props);
|
||||
return true;
|
||||
} else if (IsTypedArrayKey(key)) {
|
||||
uint32_t length = JS_GetTypedArrayLength(target);
|
||||
// TypedArrays enumerate every indexed property in range, but
|
||||
@ -1729,8 +1726,6 @@ XPCWrappedNativeXrayTraits::enumerateNames(JSContext *cx, HandleObject wrapper,
|
||||
if (!js::GetPropertyNames(cx, target, flags, &wnProps))
|
||||
return false;
|
||||
}
|
||||
if (!JS_WrapAutoIdVector(cx, wnProps))
|
||||
return false;
|
||||
|
||||
// Go through the properties we got and enumerate all native ones.
|
||||
if (!props.reserve(wnProps.length()))
|
||||
@ -2504,8 +2499,6 @@ XrayWrapper<Base, Traits>::enumerate(JSContext *cx, HandleObject wrapper, unsign
|
||||
if (!js::GetPropertyNames(cx, expando, flags, &props))
|
||||
return false;
|
||||
}
|
||||
if (!JS_WrapAutoIdVector(cx, props))
|
||||
return false;
|
||||
|
||||
return Traits::singleton.enumerateNames(cx, wrapper, flags, props);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user