mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 15:25:52 +00:00
Bug 952660, part 6 - Add and use nsXPCWrappedJS::FindOrFindInherited. r=bholley
FindInherited is only ever used after running Find, and the way the checks are chained is a little weird.
This commit is contained in:
parent
a4ebfe78ef
commit
80cd1878d3
@ -351,8 +351,8 @@ nsXPCWrappedJS::GetNewOrUsed(JS::HandleObject jsObj,
|
||||
|
||||
root = map->Find(rootJSObj);
|
||||
if (root) {
|
||||
if ((nullptr != (wrapper = root->Find(aIID))) ||
|
||||
(nullptr != (wrapper = root->FindInherited(aIID)))) {
|
||||
wrapper = root->FindOrFindInherited(aIID);
|
||||
if (wrapper) {
|
||||
NS_ADDREF(wrapper);
|
||||
*wrapperResult = wrapper;
|
||||
return NS_OK;
|
||||
|
@ -614,19 +614,11 @@ nsXPCWrappedJSClass::DelegatedQueryInterface(nsXPCWrappedJS* self,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsXPCWrappedJS* sibling;
|
||||
|
||||
// Checks for any existing wrapper explicitly constructed for this iid.
|
||||
// This includes the current 'self' wrapper. This also deals with the
|
||||
// nsISupports case (for which it returns mRoot).
|
||||
if (nullptr != (sibling = self->Find(aIID))) {
|
||||
NS_ADDREF(sibling);
|
||||
*aInstancePtr = sibling->GetXPTCStub();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Check if asking for an interface from which one of our wrappers inherits.
|
||||
if (nullptr != (sibling = self->FindInherited(aIID))) {
|
||||
// Also check if asking for an interface from which one of our wrappers inherits.
|
||||
if (nsXPCWrappedJS* sibling = self->FindOrFindInherited(aIID)) {
|
||||
NS_ADDREF(sibling);
|
||||
*aInstancePtr = sibling->GetXPTCStub();
|
||||
return NS_OK;
|
||||
|
@ -2495,6 +2495,12 @@ public:
|
||||
|
||||
nsXPCWrappedJS* Find(REFNSIID aIID);
|
||||
nsXPCWrappedJS* FindInherited(REFNSIID aIID);
|
||||
nsXPCWrappedJS* FindOrFindInherited(REFNSIID aIID) {
|
||||
nsXPCWrappedJS* wrapper = Find(aIID);
|
||||
if (wrapper)
|
||||
return wrapper;
|
||||
return FindInherited(aIID);
|
||||
}
|
||||
|
||||
bool IsRootWrapper() const {return mRoot == this;}
|
||||
bool IsValid() const {return mJSObj != nullptr;}
|
||||
|
Loading…
Reference in New Issue
Block a user