Bug 1611173 - Remove support for non-nsISupports XPIDL interfaces. r=nika

It used to be that some XPIDL interfaces were allowed to be non-nsISupports,
and were only used to hold a bunch of constants. It appears that we've now
had enough de-COM work happen that there are no longer any, so we can remove
support for this.

Differential Revision: https://phabricator.services.mozilla.com/D61008

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew McCreight 2020-01-24 21:34:24 +00:00
parent 7bfc3e2bf5
commit ba3997abc8
7 changed files with 5 additions and 34 deletions

View File

@ -97,11 +97,7 @@ class MOZ_STACK_CLASS AutoSavePendingResult {
// static
const nsXPTInterfaceInfo* nsXPCWrappedJS::GetInterfaceInfo(REFNSIID aIID) {
const nsXPTInterfaceInfo* info = nsXPTInterfaceInfo::ByIID(aIID);
if (!info) {
return nullptr;
}
if (info->IsBuiltinClass() || !nsXPConnect::IsISupportsDescendant(info)) {
if (!info || info->IsBuiltinClass()) {
return nullptr;
}

View File

@ -248,16 +248,6 @@ already_AddRefed<XPCNativeInterface> XPCNativeInterface::NewInstance(
uint16_t methodCount = aInfo->MethodCount();
uint16_t constCount = aInfo->ConstantCount();
// If the interface does not have nsISupports in its inheritance chain
// then we know we can't reflect its methods. However, some interfaces that
// are used just to reflect constants are declared this way. We need to
// go ahead and build the thing. But, we'll ignore whatever methods it may
// have.
if (!nsXPConnect::IsISupportsDescendant(aInfo)) {
methodCount = 0;
}
totalCount = methodCount + constCount;
if (totalCount > MAX_LOCAL_MEMBER_COUNT) {

View File

@ -166,11 +166,6 @@ XPCJSRuntime* nsXPConnect::GetRuntimeInstance() {
return gSelf->mRuntime;
}
// static
bool nsXPConnect::IsISupportsDescendant(const nsXPTInterfaceInfo* info) {
return info && info->HasAncestor(NS_GET_IID(nsISupports));
}
void xpc::ErrorBase::Init(JSErrorBase* aReport) {
if (!aReport->filename) {
mFileName.SetIsVoid(true);

View File

@ -226,8 +226,6 @@ class nsXPConnect final : public nsIXPConnect {
static XPCJSRuntime* GetRuntimeInstance();
XPCJSContext* GetContext() { return mContext; }
static bool IsISupportsDescendant(const nsXPTInterfaceInfo* info);
static nsIScriptSecurityManager* SecurityManager() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(gScriptSecurityManager);

View File

@ -479,12 +479,7 @@ def write_interface(iface, fd):
if iface.namemap is None:
raise Exception("Interface was not resolved.")
# if we see a base class-less type other than nsISupports, we just need
# to discard anything else about it other than its constants.
if iface.base is None and iface.name != "nsISupports":
assert len([m for m in iface.members
if type(m) == xpidl.Attribute or type(m) == xpidl.Method]) == 0
return
assert iface.base or (iface.name == "nsISupports")
# Extract the UUID's information so that it can be written into the struct definition
names = uuid_decoder.match(iface.attributes.uuid).groupdict()

View File

@ -51,12 +51,7 @@ def write_interface(iface, fd):
if iface.namemap is None:
raise Exception("Interface was not resolved.")
# if we see a base class-less type other than nsISupports, we just need
# to discard anything else about it other than its constants.
if iface.base is None and iface.name != "nsISupports":
assert len([m for m in iface.members
if type(m) == xpidl.Attribute or type(m) == xpidl.Method]) == 0
return
assert iface.base or (iface.name == "nsISupports")
base = 'Some("%s")' % iface.base if iface.base is not None else 'None'
try:

View File

@ -704,6 +704,8 @@ class Interface(object):
raise IDLError("interface '%s' is not builtinclass but derives from "
"builtinclass '%s'" %
(self.name, self.base), self.location)
elif self.name != 'nsISupports':
raise IDLError("Interface '%s' must inherit from nsISupports" % self.name, self.location)
for member in self.members:
member.resolve(self)