зеркало из https://github.com/mozilla/gecko-dev.git
Bug 993026 - Change resolve hook in browser/XPC. r=bholley
This commit is contained in:
Родитель
cc421a900c
Коммит
18c9617c27
|
@ -2292,15 +2292,9 @@ FinalizeGlobal(JSFreeOp* aFreeOp, JSObject* aObj)
|
|||
|
||||
bool
|
||||
ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId, JS::MutableHandle<JSObject*> aObjp)
|
||||
JS::Handle<jsid> aId, bool* aResolvedp)
|
||||
{
|
||||
bool resolved;
|
||||
if (!JS_ResolveStandardClass(aCx, aObj, aId, &resolved)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aObjp.set(resolved ? aObj.get() : nullptr);
|
||||
return true;
|
||||
return JS_ResolveStandardClass(aCx, aObj, aId, aResolvedp);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -2803,7 +2803,7 @@ FinalizeGlobal(JSFreeOp* aFop, JSObject* aObj);
|
|||
|
||||
bool
|
||||
ResolveGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
JS::Handle<jsid> aId, JS::MutableHandle<JSObject*> aObjp);
|
||||
JS::Handle<jsid> aId, bool* aResolvedp);
|
||||
|
||||
bool
|
||||
EnumerateGlobal(JSContext* aCx, JS::Handle<JSObject*> aObj);
|
||||
|
|
|
@ -419,12 +419,10 @@ class CGDOMJSClass(CGThing):
|
|||
classFlags += "JSCLASS_HAS_RESERVED_SLOTS(%d)" % slotCount
|
||||
reservedSlots = slotCount
|
||||
if self.descriptor.interface.getExtendedAttribute("NeedNewResolve"):
|
||||
newResolveHook = "(JSResolveOp)" + NEWRESOLVE_HOOK_NAME
|
||||
classFlags += " | JSCLASS_NEW_RESOLVE"
|
||||
newResolveHook = NEWRESOLVE_HOOK_NAME
|
||||
enumerateHook = ENUMERATE_HOOK_NAME
|
||||
elif self.descriptor.isGlobal():
|
||||
newResolveHook = "(JSResolveOp) mozilla::dom::ResolveGlobal"
|
||||
classFlags += " | JSCLASS_NEW_RESOLVE"
|
||||
newResolveHook = "mozilla::dom::ResolveGlobal"
|
||||
enumerateHook = "mozilla::dom::EnumerateGlobal"
|
||||
else:
|
||||
newResolveHook = "JS_ResolveStub"
|
||||
|
@ -7609,7 +7607,7 @@ class CGNewResolveHook(CGAbstractBindingMethod):
|
|||
args = [Argument('JSContext*', 'cx'),
|
||||
Argument('JS::Handle<JSObject*>', 'obj'),
|
||||
Argument('JS::Handle<jsid>', 'id'),
|
||||
Argument('JS::MutableHandle<JSObject*>', 'objp')]
|
||||
Argument('bool*', 'resolvedp')]
|
||||
# Our "self" is actually the "obj" argument in this case, not the thisval.
|
||||
CGAbstractBindingMethod.__init__(
|
||||
self, descriptor, NEWRESOLVE_HOOK_NAME,
|
||||
|
@ -7634,7 +7632,7 @@ class CGNewResolveHook(CGAbstractBindingMethod):
|
|||
JS_PROPERTYOP_SETTER(desc.setter()))) {
|
||||
return false;
|
||||
}
|
||||
objp.set(obj);
|
||||
*resolvedp = true;
|
||||
return true;
|
||||
"""))
|
||||
|
||||
|
@ -7642,10 +7640,10 @@ class CGNewResolveHook(CGAbstractBindingMethod):
|
|||
if self.descriptor.isGlobal():
|
||||
# Resolve standard classes
|
||||
prefix = dedent("""
|
||||
if (!ResolveGlobal(cx, obj, id, objp)) {
|
||||
if (!ResolveGlobal(cx, obj, id, resolvedp)) {
|
||||
return false;
|
||||
}
|
||||
if (objp) {
|
||||
if (*resolvedp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JS::Handle<JSObject*> obj, JSIterateOp
|
|||
|
||||
static bool
|
||||
NPObjWrapper_NewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JS::MutableHandle<JSObject*> objp);
|
||||
bool *resolvedp);
|
||||
|
||||
static bool
|
||||
NPObjWrapper_Convert(JSContext *cx, JS::Handle<JSObject*> obj, JSType type, JS::MutableHandle<JS::Value> vp);
|
||||
|
@ -184,13 +184,13 @@ CreateNPObjectMember(NPP npp, JSContext *cx, JSObject *obj, NPObject* npobj,
|
|||
const static js::Class sNPObjectJSWrapperClass =
|
||||
{
|
||||
NPRUNTIME_JSCLASS_NAME,
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_NEW_RESOLVE | JSCLASS_NEW_ENUMERATE,
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_IMPLEMENTS_BARRIERS | JSCLASS_NEW_ENUMERATE,
|
||||
NPObjWrapper_AddProperty,
|
||||
NPObjWrapper_DelProperty,
|
||||
NPObjWrapper_GetProperty,
|
||||
NPObjWrapper_SetProperty,
|
||||
(JSEnumerateOp)NPObjWrapper_newEnumerate,
|
||||
(JSResolveOp)NPObjWrapper_NewResolve,
|
||||
NPObjWrapper_NewResolve,
|
||||
NPObjWrapper_Convert,
|
||||
NPObjWrapper_Finalize,
|
||||
NPObjWrapper_Call,
|
||||
|
@ -1654,7 +1654,7 @@ NPObjWrapper_newEnumerate(JSContext *cx, JS::Handle<JSObject*> obj, JSIterateOp
|
|||
|
||||
static bool
|
||||
NPObjWrapper_NewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
|
||||
JS::MutableHandle<JSObject*> objp)
|
||||
bool *resolvedp)
|
||||
{
|
||||
if (JSID_IS_SYMBOL(id))
|
||||
return true;
|
||||
|
@ -1684,7 +1684,7 @@ NPObjWrapper_NewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsi
|
|||
return false;
|
||||
}
|
||||
|
||||
objp.set(obj);
|
||||
*resolvedp = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1700,7 +1700,7 @@ NPObjWrapper_NewResolve(JSContext *cx, JS::Handle<JSObject*> obj, JS::Handle<jsi
|
|||
JSFunction *fnc = ::JS_DefineFunctionById(cx, obj, id, CallNPMethod, 0,
|
||||
JSPROP_ENUMERATE);
|
||||
|
||||
objp.set(obj);
|
||||
*resolvedp = true;
|
||||
|
||||
return fnc != nullptr;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,6 @@ XBLEnumerate(JSContext *cx, JS::Handle<JSObject*> obj)
|
|||
static const JSClass gPrototypeJSClass = {
|
||||
"XBL prototype JSClass",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS |
|
||||
JSCLASS_NEW_RESOLVE |
|
||||
// Our one reserved slot holds the relevant nsXBLPrototypeBinding
|
||||
JSCLASS_HAS_RESERVED_SLOTS(1),
|
||||
JS_PropertyStub, JS_DeletePropertyStub,
|
||||
|
|
|
@ -303,10 +303,9 @@ sandbox_enumerate(JSContext *cx, HandleObject obj)
|
|||
}
|
||||
|
||||
static bool
|
||||
sandbox_resolve(JSContext *cx, HandleObject obj, HandleId id)
|
||||
sandbox_resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
||||
{
|
||||
bool resolved;
|
||||
return JS_ResolveStandardClass(cx, obj, id, &resolved);
|
||||
return JS_ResolveStandardClass(cx, obj, id, resolvedp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -743,8 +743,7 @@ env_enumerate(JSContext *cx, HandleObject obj)
|
|||
}
|
||||
|
||||
static bool
|
||||
env_resolve(JSContext *cx, HandleObject obj, HandleId id,
|
||||
JS::MutableHandleObject objp)
|
||||
env_resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
||||
{
|
||||
JSString *idstr;
|
||||
|
||||
|
@ -766,16 +765,16 @@ env_resolve(JSContext *cx, HandleObject obj, HandleId id,
|
|||
if (!JS_DefinePropertyById(cx, obj, id, valstr, JSPROP_ENUMERATE)) {
|
||||
return false;
|
||||
}
|
||||
objp.set(obj);
|
||||
*resolvedp = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static const JSClass env_class = {
|
||||
"environment", JSCLASS_HAS_PRIVATE | JSCLASS_NEW_RESOLVE,
|
||||
"environment", JSCLASS_HAS_PRIVATE,
|
||||
JS_PropertyStub, JS_DeletePropertyStub,
|
||||
JS_PropertyStub, env_setProperty,
|
||||
env_enumerate, (JSResolveOp) env_resolve,
|
||||
env_enumerate, env_resolve,
|
||||
JS_ConvertStub, nullptr
|
||||
};
|
||||
|
||||
|
|
|
@ -623,7 +623,7 @@ XPCWrappedNative::Trace(JSTracer *trc, JSObject *obj)
|
|||
}
|
||||
|
||||
static bool
|
||||
XPC_WN_NoHelper_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
||||
XPC_WN_NoHelper_Resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
||||
{
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj, NullPtr(), id);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
|
@ -642,7 +642,8 @@ XPC_WN_NoHelper_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
|||
true, wrapper, wrapper, nullptr,
|
||||
JSPROP_ENUMERATE |
|
||||
JSPROP_READONLY |
|
||||
JSPROP_PERMANENT, nullptr);
|
||||
JSPROP_PERMANENT,
|
||||
resolvedp);
|
||||
}
|
||||
|
||||
const XPCWrappedNativeJSClass XPC_WN_NoHelper_JSClass = {
|
||||
|
@ -856,8 +857,7 @@ XPC_WN_Helper_Finalize(js::FreeOp *fop, JSObject *obj)
|
|||
}
|
||||
|
||||
static bool
|
||||
XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
||||
MutableHandleObject objp)
|
||||
XPC_WN_Helper_Resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
bool retval = true;
|
||||
|
@ -890,7 +890,7 @@ XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
|||
}
|
||||
|
||||
if (resolved) {
|
||||
objp.set(obj);
|
||||
*resolvedp = true;
|
||||
} else if (wrapper->HasMutatedSet()) {
|
||||
// We are here if scriptable did not resolve this property and
|
||||
// it *might* be in the instance set but not the proto set.
|
||||
|
@ -916,7 +916,6 @@ XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
|||
XPCWrappedNative* wrapperForInterfaceNames =
|
||||
siFlags.DontReflectInterfaceNames() ? nullptr : wrapper;
|
||||
|
||||
bool resolved;
|
||||
oldResolvingWrapper = ccx.SetResolvingWrapper(wrapper);
|
||||
retval = DefinePropertyIfFound(ccx, obj, id,
|
||||
set, iface, member,
|
||||
|
@ -924,10 +923,8 @@ XPC_WN_Helper_NewResolve(JSContext *cx, HandleObject obj, HandleId id,
|
|||
false,
|
||||
wrapperForInterfaceNames,
|
||||
nullptr, si,
|
||||
enumFlag, &resolved);
|
||||
enumFlag, resolvedp);
|
||||
(void)ccx.SetResolvingWrapper(oldResolvingWrapper);
|
||||
if (retval && resolved)
|
||||
objp.set(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1095,8 +1092,7 @@ XPCNativeScriptableShared::PopulateJSClass()
|
|||
MOZ_ASSERT(mJSClass.base.name, "bad state!");
|
||||
|
||||
mJSClass.base.flags = WRAPPER_SLOTS |
|
||||
JSCLASS_PRIVATE_IS_NSISUPPORTS |
|
||||
JSCLASS_NEW_RESOLVE;
|
||||
JSCLASS_PRIVATE_IS_NSISUPPORTS;
|
||||
|
||||
if (mFlags.IsGlobalObject())
|
||||
mJSClass.base.flags |= XPCONNECT_GLOBAL_FLAGS;
|
||||
|
@ -1148,7 +1144,7 @@ XPCNativeScriptableShared::PopulateJSClass()
|
|||
mJSClass.base.enumerate = XPC_WN_Shared_Enumerate;
|
||||
|
||||
// We have to figure out resolve strategy at call time
|
||||
mJSClass.base.resolve = (JSResolveOp) XPC_WN_Helper_NewResolve;
|
||||
mJSClass.base.resolve = XPC_WN_Helper_Resolve;
|
||||
|
||||
if (mFlags.WantConvert())
|
||||
mJSClass.base.convert = XPC_WN_Helper_Convert;
|
||||
|
@ -1357,7 +1353,7 @@ XPC_WN_Shared_Proto_Trace(JSTracer *trc, JSObject *obj)
|
|||
/*****************************************************/
|
||||
|
||||
static bool
|
||||
XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
||||
XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvep)
|
||||
{
|
||||
MOZ_ASSERT(js::GetObjectClass(obj) == &XPC_WN_ModsAllowed_WithCall_Proto_JSClass ||
|
||||
js::GetObjectClass(obj) == &XPC_WN_ModsAllowed_NoCall_Proto_JSClass,
|
||||
|
@ -1380,7 +1376,7 @@ XPC_WN_ModsAllowed_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
|||
self->GetSet(), nullptr, nullptr,
|
||||
self->GetScope(),
|
||||
true, nullptr, nullptr, si,
|
||||
enumFlag, nullptr);
|
||||
enumFlag, resolvep);
|
||||
}
|
||||
|
||||
#define XPC_WN_SHARED_PROTO_CLASS_EXT \
|
||||
|
@ -1476,7 +1472,7 @@ XPC_WN_OnlyIWrite_Proto_SetPropertyStub(JSContext *cx, HandleObject obj, HandleI
|
|||
}
|
||||
|
||||
static bool
|
||||
XPC_WN_NoMods_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
||||
XPC_WN_NoMods_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
||||
{
|
||||
MOZ_ASSERT(js::GetObjectClass(obj) == &XPC_WN_NoMods_WithCall_Proto_JSClass ||
|
||||
js::GetObjectClass(obj) == &XPC_WN_NoMods_NoCall_Proto_JSClass,
|
||||
|
@ -1501,7 +1497,7 @@ XPC_WN_NoMods_Proto_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
|||
true, nullptr, nullptr, si,
|
||||
JSPROP_READONLY |
|
||||
JSPROP_PERMANENT |
|
||||
enumFlag, nullptr);
|
||||
enumFlag, resolvedp);
|
||||
}
|
||||
|
||||
const js::Class XPC_WN_NoMods_WithCall_Proto_JSClass = {
|
||||
|
@ -1579,7 +1575,7 @@ XPC_WN_TearOff_Enumerate(JSContext *cx, HandleObject obj)
|
|||
}
|
||||
|
||||
static bool
|
||||
XPC_WN_TearOff_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
||||
XPC_WN_TearOff_Resolve(JSContext *cx, HandleObject obj, HandleId id, bool *resolvedp)
|
||||
{
|
||||
XPCCallContext ccx(JS_CALLER, cx, obj);
|
||||
XPCWrappedNative* wrapper = ccx.GetWrapper();
|
||||
|
@ -1596,7 +1592,7 @@ XPC_WN_TearOff_Resolve(JSContext *cx, HandleObject obj, HandleId id)
|
|||
true, nullptr, nullptr, nullptr,
|
||||
JSPROP_READONLY |
|
||||
JSPROP_PERMANENT |
|
||||
JSPROP_ENUMERATE, nullptr);
|
||||
JSPROP_ENUMERATE, resolvedp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Загрузка…
Ссылка в новой задаче