Bug 1442039 part 1. Remove the now-useless nsScriptNameSpaceManager::RegisterClassProto function. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 21 Mar 2018 23:13:28 -0400
changeset 409436 5900a3a5a232a63ef9f437952df49a0ca6443e48
parent 409435 03ec4b083bf30184b849f6e6ee9aee4d7535c85a
child 409437 e75da32a2992ca10092e328f81af0d1ca7ddd08b
push id33687
push userapavel@mozilla.com
push dateThu, 22 Mar 2018 09:31:48 +0000
treeherdermozilla-central@7771df14ea18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv
bugs1442039
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1442039 part 1. Remove the now-useless nsScriptNameSpaceManager::RegisterClassProto function. r=peterv The only caller is nsDOMClassInfo::RegisterClassProtos. The only caller of that is nsDOMClassInfo::Init. In nsDOMClassInfo::Init this is called after we have done the RegisterClassName call for "DOMConstructor". Since the only bits of classinfo left are DOMConstructor and DOMPrototype, and both use nsIDOMDOMConstructor as their interface, we call RegisterClassProto with "DOMConstructor" as aClassName, find the existing nsGlobalNameStruct, and return without doing anything. So this entire codepath can be removed. MozReview-Commit-ID: JfXmIex7tLC
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfo.h
dom/base/nsScriptNameSpaceManager.cpp
dom/base/nsScriptNameSpaceManager.h
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -261,68 +261,16 @@ CutPrefix(const char *aName) {
 
   if (strncmp(aName, prefix_nsI, sizeof(prefix_nsI) - 1) == 0) {
     return aName + sizeof(prefix_nsI) - 1;
   }
 
   return aName;
 }
 
-// static
-nsresult
-nsDOMClassInfo::RegisterClassProtos(int32_t aClassInfoID)
-{
-  nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
-  NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
-  bool found_old;
-
-  const nsIID *primary_iid = sClassInfoData[aClassInfoID].mProtoChainInterface;
-
-  if (!primary_iid || primary_iid == &NS_GET_IID(nsISupports)) {
-    return NS_OK;
-  }
-
-  nsCOMPtr<nsIInterfaceInfoManager>
-    iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
-  NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
-
-  nsCOMPtr<nsIInterfaceInfo> if_info;
-  bool first = true;
-
-  iim->GetInfoForIID(primary_iid, getter_AddRefs(if_info));
-
-  while (if_info) {
-    const nsIID *iid = nullptr;
-
-    if_info->GetIIDShared(&iid);
-    NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
-
-    if (iid->Equals(NS_GET_IID(nsISupports))) {
-      break;
-    }
-
-    const char *name = nullptr;
-    if_info->GetNameShared(&name);
-    NS_ENSURE_TRUE(name, NS_ERROR_UNEXPECTED);
-
-    nameSpaceManager->RegisterClassProto(CutPrefix(name), iid, &found_old);
-
-    if (first) {
-      first = false;
-    } else if (found_old) {
-      break;
-    }
-
-    nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
-    tmp->GetParent(getter_AddRefs(if_info));
-  }
-
-  return NS_OK;
-}
-
 #define _DOM_CLASSINFO_MAP_BEGIN(_class, _ifptr, _has_class_if)               \
   {                                                                           \
     nsDOMClassInfoData &d = sClassInfoData[eDOMClassInfo_##_class##_id];      \
     d.mProtoChainInterface = _ifptr;                                          \
     d.mHasClassInterface = _has_class_if;                                     \
     static const nsIID *interface_list[] = {
 
 #define DOM_CLASSINFO_MAP_BEGIN(_class, _interface)                           \
@@ -419,20 +367,16 @@ nsDOMClassInfo::Init()
     if (i == eDOMClassInfo_DOMPrototype_id) {
       continue;
     }
 
     nsDOMClassInfoData& data = sClassInfoData[i];
     nameSpaceManager->RegisterClassName(data.mClass.name, i, &data.mNameUTF16);
   }
 
-  for (i = 0; i < eDOMClassInfoIDCount; ++i) {
-    RegisterClassProtos(i);
-  }
-
   sIsInitialized = true;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMClassInfo::GetInterfaces(uint32_t *aCount, nsIID ***aArray)
 {
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -95,18 +95,16 @@ protected:
   friend nsIClassInfo* NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
 
   const nsDOMClassInfoData* mData;
 
   virtual void PreserveWrapper(nsISupports *aNative) override
   {
   }
 
-  static nsresult RegisterClassProtos(int32_t aDOMClassInfoID);
-
   static nsIXPConnect *sXPConnect;
 
   // nsIXPCScriptable code
   static nsresult DefineStaticJSVals();
 
   static bool sIsInitialized;
 
 public:
--- a/dom/base/nsScriptNameSpaceManager.cpp
+++ b/dom/base/nsScriptNameSpaceManager.cpp
@@ -222,40 +222,16 @@ nsScriptNameSpaceManager::RegisterClassN
 
   s->mType = nsGlobalNameStruct::eTypeClassConstructor;
   s->mDOMClassInfoID = aDOMClassInfoID;
 
   return NS_OK;
 }
 
 nsresult
-nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
-                                             const nsIID *aConstructorProtoIID,
-                                             bool *aFoundOld)
-{
-  NS_ENSURE_ARG_POINTER(aConstructorProtoIID);
-
-  *aFoundOld = false;
-
-  nsGlobalNameStruct *s = AddToHash(aClassName);
-  NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
-
-  if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
-    *aFoundOld = true;
-
-    return NS_OK;
-  }
-
-  s->mType = nsGlobalNameStruct::eTypeClassProto;
-  s->mIID = *aConstructorProtoIID;
-
-  return NS_OK;
-}
-
-nsresult
 nsScriptNameSpaceManager::OperateCategoryEntryHash(nsICategoryManager* aCategoryManager,
                                                    const char* aCategory,
                                                    nsISupports* aEntry,
                                                    bool aRemove)
 {
   MOZ_ASSERT(aCategoryManager);
   // Get the type from the category name.
   // NOTE: we could have passed the type in FillHash() and guessed it in
--- a/dom/base/nsScriptNameSpaceManager.h
+++ b/dom/base/nsScriptNameSpaceManager.h
@@ -72,20 +72,16 @@ public:
   // in the nsGlobalNameStruct.
   const nsGlobalNameStruct* LookupName(const nsAString& aName,
                                        const char16_t **aClassName = nullptr);
 
   nsresult RegisterClassName(const char *aClassName,
                              int32_t aDOMClassInfoID,
                              const char16_t **aResult);
 
-  nsresult RegisterClassProto(const char *aClassName,
-                              const nsIID *aConstructorProtoIID,
-                              bool *aFoundOld);
-
   class NameIterator : public PLDHashTable::Iterator
   {
   public:
     typedef PLDHashTable::Iterator Base;
     explicit NameIterator(PLDHashTable* aTable) : Base(aTable) {}
     NameIterator(NameIterator&& aOther) : Base(mozilla::Move(aOther.mTable)) {}
 
     const GlobalNameMapEntry* Get() const