mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1288791 part 1. Rename the GetParentObject template bits to make it clearer what they're really doing: finding the associated global for an object's native. r=bkelly
This commit is contained in:
parent
f65cc2b16c
commit
8e34004cf1
@ -2025,8 +2025,9 @@ ReparentWrapper(JSContext* aCx, JS::Handle<JSObject*> aObjArg)
|
||||
js::GetGlobalForObjectCrossCompartment(aObj));
|
||||
MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(oldParent) == oldParent);
|
||||
|
||||
JS::Rooted<JSObject*> newParent(aCx, domClass->mGetParent(aCx, aObj));
|
||||
MOZ_ASSERT(js::GetGlobalForObjectCrossCompartment(newParent) == newParent);
|
||||
JS::Rooted<JSObject*> newParent(aCx,
|
||||
domClass->mGetAssociatedGlobal(aCx, aObj));
|
||||
MOZ_ASSERT(JS_IsGlobalObject(newParent));
|
||||
|
||||
JSAutoCompartment oldAc(aCx, oldParent);
|
||||
|
||||
|
@ -1653,8 +1653,9 @@ WrapNativeParent(JSContext* cx, nsIGlobalObject* const& p)
|
||||
return p ? p->GetGlobalJSObject() : JS::CurrentGlobalOrNull(cx);
|
||||
}
|
||||
|
||||
template<typename T, bool WrapperCached=NativeHasMember<T>::GetParentObject>
|
||||
struct GetParentObject
|
||||
template<typename T,
|
||||
bool hasAssociatedGlobal=NativeHasMember<T>::GetParentObject>
|
||||
struct FindAssociatedGlobalForNative
|
||||
{
|
||||
static JSObject* Get(JSContext* cx, JS::Handle<JSObject*> obj)
|
||||
{
|
||||
@ -1666,7 +1667,7 @@ struct GetParentObject
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct GetParentObject<T, false>
|
||||
struct FindAssociatedGlobalForNative<T, false>
|
||||
{
|
||||
static JSObject* Get(JSContext* cx, JS::Handle<JSObject*> obj)
|
||||
{
|
||||
|
@ -390,7 +390,7 @@ def DOMClass(descriptor):
|
||||
{ ${protoChain} },
|
||||
IsBaseOf<nsISupports, ${nativeType} >::value,
|
||||
${hooks},
|
||||
GetParentObject<${nativeType}>::Get,
|
||||
FindAssociatedGlobalForNative<${nativeType}>::Get,
|
||||
GetProtoObjectHandle,
|
||||
GetCCParticipant<${nativeType}>::Get()
|
||||
""",
|
||||
|
@ -318,7 +318,8 @@ IsInterfacePrototype(DOMObjectType type)
|
||||
return type == eInterfacePrototype || type == eGlobalInterfacePrototype;
|
||||
}
|
||||
|
||||
typedef JSObject* (*ParentGetter)(JSContext* aCx, JS::Handle<JSObject*> aObj);
|
||||
typedef JSObject* (*AssociatedGlobalGetter)(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aObj);
|
||||
|
||||
typedef JSObject* (*ProtoGetter)(JSContext* aCx);
|
||||
|
||||
@ -351,7 +352,10 @@ struct DOMJSClass
|
||||
|
||||
const NativePropertyHooks* mNativeHooks;
|
||||
|
||||
ParentGetter mGetParent;
|
||||
// A callback to find the associated global for our C++ object. Note that
|
||||
// this is used in cases when that global is _changing_, so it will not match
|
||||
// the global of the JSObject* passed in to this function!
|
||||
AssociatedGlobalGetter mGetAssociatedGlobal;
|
||||
ProtoHandleGetter mGetProto;
|
||||
|
||||
// This stores the CC participant for the native, null if this class does not
|
||||
|
Loading…
Reference in New Issue
Block a user