Bug 1442039 part 6. Remove now-unused classinfo bits for DOMConstructor and DOMPrototype. r=peterv
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 21 Mar 2018 23:13:29 -0400
changeset 409441 b4492fdf4a10d3ffef5608f1d63e1b2191ad841a
parent 409440 96295638ca8e0fbeb5d38a27b31981f302544184
child 409442 9a44d04d09bf67136878d90299f4776f0ab355fe
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 6. Remove now-unused classinfo bits for DOMConstructor and DOMPrototype. r=peterv Also removes various code that stops compiling this way and static functions that are now unused. MozReview-Commit-ID: KHYxly2c3Id
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoID.h
dom/tests/mochitest/general/test_interfaces.js
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -52,17 +52,16 @@
 #include "mozilla/Telemetry.h"
 
 // Window scriptable helper includes
 #include "nsScriptNameSpaceManager.h"
 
 // DOM base includes
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
-#include "nsIDOMConstructor.h"
 
 // DOM core includes
 #include "nsError.h"
 
 // Event related includes
 #include "nsIDOMEventTarget.h"
 
 // CSS related includes
@@ -120,48 +119,16 @@ using namespace mozilla::dom;
     true,                                                                     \
     false,                                                                    \
     NS_DEFINE_CLASSINFO_DATA_DEBUG(_class)                                    \
   },
 
 #define NS_DEFINE_CLASSINFO_DATA(_class, _helper, _flags)                     \
   NS_DEFINE_CLASSINFO_DATA_HELPER(_class, _helper, _flags)
 
-// This list of NS_DEFINE_CLASSINFO_DATA macros is what gives the DOM
-// classes their correct behavior when used through XPConnect. The
-// arguments that are passed to NS_DEFINE_CLASSINFO_DATA are
-//
-// 1. Class name as it should appear in JavaScript, this name is also
-//    used to find the id of the class in nsDOMClassInfo
-//    (i.e. e<classname>_id)
-// 2. Scriptable helper class
-// 3. nsIClassInfo/nsIXPCScriptable flags (i.e. for GetScriptableFlags)
-
-static nsDOMClassInfoData sClassInfoData[] = {
-  // These bits are about to go away; they're unused and it doesn't
-  // matter what helper is used for them.
-  NS_DEFINE_CLASSINFO_DATA(DOMPrototype, nsDOMGenericSH,
-                           DOM_BASE_SCRIPTABLE_FLAGS |
-                           XPC_SCRIPTABLE_WANT_PRECREATE |
-                           XPC_SCRIPTABLE_WANT_RESOLVE |
-                           XPC_SCRIPTABLE_WANT_HASINSTANCE |
-                           XPC_SCRIPTABLE_DONT_ENUM_QUERY_INTERFACE)
-  NS_DEFINE_CLASSINFO_DATA(DOMConstructor, nsDOMGenericSH,
-                           DOM_BASE_SCRIPTABLE_FLAGS |
-                           XPC_SCRIPTABLE_WANT_PRECREATE |
-                           XPC_SCRIPTABLE_WANT_RESOLVE |
-                           XPC_SCRIPTABLE_WANT_HASINSTANCE |
-                           XPC_SCRIPTABLE_WANT_CALL |
-                           XPC_SCRIPTABLE_WANT_CONSTRUCT |
-                           XPC_SCRIPTABLE_DONT_ENUM_QUERY_INTERFACE)
-
-  // Misc Core related classes
-
-};
-
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nullptr;
 bool nsDOMClassInfo::sIsInitialized = false;
 
 
 jsid nsDOMClassInfo::sConstructor_id     = JSID_VOID;
 jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
 
 // Helper to handle torn-down inner windows.
@@ -288,60 +255,19 @@ nsDOMClassInfo::Init()
   nsScriptNameSpaceManager *nameSpaceManager = GetNameSpaceManager();
   NS_ENSURE_TRUE(nameSpaceManager, NS_ERROR_NOT_INITIALIZED);
 
   NS_ADDREF(sXPConnect = nsContentUtils::XPConnect());
 
   nsCOMPtr<nsIXPCFunctionThisTranslator> elt = new nsEventListenerThisTranslator();
   sXPConnect->SetFunctionThisTranslator(NS_GET_IID(nsIDOMEventListener), elt);
 
-  DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(DOMPrototype, nsIDOMDOMConstructor)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
-  DOM_CLASSINFO_MAP_END
-
-  DOM_CLASSINFO_MAP_BEGIN(DOMConstructor, nsIDOMDOMConstructor)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMConstructor)
-  DOM_CLASSINFO_MAP_END
-
-  static_assert(MOZ_ARRAY_LENGTH(sClassInfoData) == eDOMClassInfoIDCount,
-                "The number of items in sClassInfoData doesn't match the "
-                "number of nsIDOMClassInfo ID's, this is bad! Fix it!");
-
-#ifdef DEBUG
-  for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
-    if (!sClassInfoData[i].mConstructorFptr ||
-        sClassInfoData[i].mDebugID != i) {
-      MOZ_CRASH("Class info data out of sync, you forgot to update "
-                "nsDOMClassInfo.h and nsDOMClassInfo.cpp! Fix this, "
-                "mozilla will not work without this fixed!");
-    }
-  }
-
-  for (size_t i = 0; i < eDOMClassInfoIDCount; i++) {
-    if (!sClassInfoData[i].mInterfaces) {
-      MOZ_CRASH("Class info data without an interface list! Fix this, "
-                "mozilla will not work without this fixed!");
-     }
-   }
-#endif
-
   // Initialize static JSString's
   DefineStaticJSVals();
 
-  int32_t i;
-
-  for (i = 0; i < eDOMClassInfoIDCount; ++i) {
-    if (i == eDOMClassInfo_DOMPrototype_id) {
-      continue;
-    }
-
-    nsDOMClassInfoData& data = sClassInfoData[i];
-    nameSpaceManager->RegisterClassName(data.mClass.name, i, &data.mNameUTF16);
-  }
-
   sIsInitialized = true;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMClassInfo::GetInterfaces(uint32_t *aCount, nsIID ***aArray)
 {
@@ -546,49 +472,23 @@ nsDOMClassInfo::PostCreatePrototype(JSCo
   // people look up "DOMConstructor".
   return NS_OK;
 }
 
 // static
 nsIClassInfo *
 NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID)
 {
-  if (aID >= eDOMClassInfoIDCount) {
-    NS_ERROR("Bad ID!");
-
-    return nullptr;
-  }
-
-  nsresult rv = RegisterDOMNames();
-  NS_ENSURE_SUCCESS(rv, nullptr);
-
-  if (!sClassInfoData[aID].mCachedClassInfo) {
-    nsDOMClassInfoData& data = sClassInfoData[aID];
-
-    data.mCachedClassInfo = data.mConstructorFptr(&data);
-    NS_ENSURE_TRUE(data.mCachedClassInfo, nullptr);
-
-    NS_ADDREF(data.mCachedClassInfo);
-  }
-
-  return sClassInfoData[aID].mCachedClassInfo;
+  return nullptr;
 }
 
 // static
 void
 nsDOMClassInfo::ShutDown()
 {
-  if (sClassInfoData[0].mConstructorFptr) {
-    uint32_t i;
-
-    for (i = 0; i < eDOMClassInfoIDCount; i++) {
-      NS_IF_RELEASE(sClassInfoData[i].mCachedClassInfo);
-    }
-  }
-
   sConstructor_id     = JSID_VOID;
   sWrappedJSObject_id = JSID_VOID;
 
   NS_IF_RELEASE(sXPConnect);
   sIsInitialized = false;
 }
 
 static nsresult
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -11,19 +11,16 @@
 
 #ifndef nsDOMClassInfoID_h__
 #define nsDOMClassInfoID_h__
 
 #include "nsIXPCScriptable.h"
 
 enum nsDOMClassInfoID
 {
-  eDOMClassInfo_DOMPrototype_id,
-  eDOMClassInfo_DOMConstructor_id,
-
   // This one better be the last one in this list
   eDOMClassInfoIDCount
 };
 
 /**
  * nsIClassInfo helper macros
  */
 
--- a/dom/tests/mochitest/general/test_interfaces.js
+++ b/dom/tests/mochitest/general/test_interfaces.js
@@ -308,18 +308,16 @@ var interfaceNamesInGlobalScope =
     {name: "Document", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DocumentFragment", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DocumentTimeline", insecureContext: true, release: false},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DocumentType", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
-    {name: "DOMConstructor", insecureContext: true, xbl: true},
-// IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DOMCursor", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DOMError", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DOMException", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!
     {name: "DOMImplementation", insecureContext: true},
 // IMPORTANT: Do not change this list without review from a DOM peer!