Bug 742837 - Remove dead code and cleanup around nsDOMScriptObjectFactory; r=bz
authorMs2ger <ms2ger@gmail.com>
Sat, 14 Apr 2012 15:03:16 +0200
changeset 95014 bb0cd5bd2edaf7a483bc30e7a8e512002e042728
parent 95013 b368955edd07b8ca3a92deec28862083f9bf9f2a
child 95015 c661a8fe157a2f6e37e8bc2346d96d45f9b7d24d
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs742837
milestone14.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 742837 - Remove dead code and cleanup around nsDOMScriptObjectFactory; r=bz
content/base/public/nsContentUtils.h
docshell/base/nsDocShell.cpp
dom/base/nsDOMScriptObjectFactory.cpp
dom/base/nsDOMScriptObjectFactory.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsIDOMScriptObjectFactory.h
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -390,19 +390,16 @@ public:
   static PRUint32 CopyNewlineNormalizedUnicodeTo(const nsAString& aSource,
                                                  PRUint32 aSrcOffset,
                                                  PRUnichar* aDest,
                                                  PRUint32 aLength,
                                                  bool& aLastCharCR);
 
   static PRUint32 CopyNewlineNormalizedUnicodeTo(nsReadingIterator<PRUnichar>& aSrcStart, const nsReadingIterator<PRUnichar>& aSrcEnd, nsAString& aDest);
 
-  static nsISupports *
-  GetClassInfoInstance(nsDOMClassInfoID aID);
-
   static const nsDependentSubstring TrimCharsInSet(const char* aSet,
                                                    const nsAString& aValue);
 
   template<bool IsWhitespace(PRUnichar)>
   static const nsDependentSubstring TrimWhitespace(const nsAString& aStr,
                                                    bool aTrimTrailing = true);
 
   /**
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -164,16 +164,17 @@
 #include "nsIStructuredCloneContainer.h"
 #include "nsIFaviconService.h"
 #include "mozIAsyncFavicons.h"
 
 // Editor-related
 #include "nsIEditingSession.h"
 
 #include "nsPIDOMWindow.h"
+#include "nsGlobalWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsIDOMDocument.h"
 #include "nsICachingChannel.h"
 #include "nsICacheVisitor.h"
 #include "nsICacheEntryDescriptor.h"
 #include "nsIMultiPartChannel.h"
 #include "nsIWyciwygChannel.h"
 
@@ -10850,46 +10851,37 @@ nsDocShell::EnsureScriptEnvironment()
                  "within EnsureScriptEnvironment()!");
 
     // Yeah, this isn't re-entrant safe, but that's ok since if we
     // re-enter this method, we'll infinitely loop...
     AutoRestore<bool> boolSetter(mInEnsureScriptEnv);
     mInEnsureScriptEnv = true;
 #endif
 
-    nsCOMPtr<nsIDOMScriptObjectFactory> factory =
-        do_GetService(kDOMScriptObjectFactoryCID);
-    NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
-
     nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(mTreeOwner));
     NS_ENSURE_TRUE(browserChrome, NS_ERROR_NOT_AVAILABLE);
 
     PRUint32 chromeFlags;
     browserChrome->GetChromeFlags(&chromeFlags);
 
     bool isModalContentWindow =
         (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL) &&
         !(chromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME);
 
     // If our window is modal and we're not opened as chrome, make
     // this window a modal content window.
-    factory->NewScriptGlobalObject(mItemType == typeChrome,
-                                   isModalContentWindow,
-                                   getter_AddRefs(mScriptGlobal));
-    NS_ENSURE_TRUE(mScriptGlobal, NS_ERROR_FAILURE);
-
-    nsCOMPtr<nsPIDOMWindow> win(do_QueryInterface(mScriptGlobal));
-    win->SetDocShell(static_cast<nsIDocShell *>(this));
+    nsRefPtr<nsGlobalWindow> window =
+        NS_NewScriptGlobalObject(mItemType == typeChrome, isModalContentWindow);
+    MOZ_ASSERT(window);
+    mScriptGlobal = window;
+
+    window->SetDocShell(this);
 
     // Ensure the script object is set up to run script.
-    nsresult rv;
-    rv = mScriptGlobal->EnsureScriptEnvironment();
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    return NS_OK;
+    return mScriptGlobal->EnsureScriptEnvironment();
 }
 
 
 NS_IMETHODIMP
 nsDocShell::EnsureEditorData()
 {
     bool openDocHasDetachedEditor = mOSHE && mOSHE->HasDetachedEditor();
     if (!mEditorData && !mIsBeingDestroyed && !openDocHasDetachedEditor) {
--- a/dom/base/nsDOMScriptObjectFactory.cpp
+++ b/dom/base/nsDOMScriptObjectFactory.cpp
@@ -66,169 +66,53 @@
 #include "nsXULPrototypeCache.h"
 #endif
 #include "nsThreadUtils.h"
 
 static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
 
 nsIExceptionProvider* gExceptionProvider = nsnull;
 
-nsDOMScriptObjectFactory::nsDOMScriptObjectFactory() :
-  mLoadedAllLanguages(false)
+nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
 {
   nsCOMPtr<nsIObserverService> observerService =
     mozilla::services::GetObserverService();
   if (observerService) {
     observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
   }
 
-  nsCOMPtr<nsIExceptionProvider> provider(new nsDOMExceptionProvider());
-  if (provider) {
-    nsCOMPtr<nsIExceptionService> xs =
-      do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
+  nsCOMPtr<nsIExceptionProvider> provider = new nsDOMExceptionProvider();
+  nsCOMPtr<nsIExceptionService> xs =
+    do_GetService(NS_EXCEPTIONSERVICE_CONTRACTID);
 
-    if (xs) {
-      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM);
-      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG);
-      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH);
-      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB);
-      xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_XPCONNECT);
-    }
-
-    NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
-    provider.swap(gExceptionProvider);
+  if (xs) {
+    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM);
+    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_SVG);
+    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_XPATH);
+    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_DOM_INDEXEDDB);
+    xs->RegisterExceptionProvider(provider, NS_ERROR_MODULE_XPCONNECT);
   }
 
+  NS_ASSERTION(!gExceptionProvider, "Registered twice?!");
+  provider.swap(gExceptionProvider);
+
   // And pre-create the javascript language.
-  NS_CreateJSRuntime(getter_AddRefs(mLanguageArray[NS_STID_INDEX(nsIProgrammingLanguage::JAVASCRIPT)]));
+  NS_CreateJSRuntime(getter_AddRefs(mJSRuntime));
 }
 
 NS_INTERFACE_MAP_BEGIN(nsDOMScriptObjectFactory)
   NS_INTERFACE_MAP_ENTRY(nsIDOMScriptObjectFactory)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMScriptObjectFactory)
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_ADDREF(nsDOMScriptObjectFactory)
 NS_IMPL_RELEASE(nsDOMScriptObjectFactory)
 
-/**
- * Notes about language registration (for language other than js):
- * - All language are expected to register (at least) 2 contract IDs
- *    @mozilla.org/script-language;1?id=%d
- *  using the language ID as defined in nsIProgrammingLanguage, and
- *    @mozilla.org/script-language;1?script-type=%s
- *  using the "mime-type" of the script language
- *
- *  Theoretically, a language could register multiple script-type
- *  names, although this is discouraged - each language should have one,
- *  canonical name.
- *
- *  The most common case is that languages are looked up by ID.  For this
- *  reason, we keep an array of languages indexed by this ID - the registry
- *  is only looked the first request for a language ID.
- *  
- *  The registry is looked up and getService called for each query by name.
- *  (As services are cached by CID, multiple contractIDs will still work
- *  correctly)
- **/
-
-NS_IMETHODIMP
-nsDOMScriptObjectFactory::GetScriptRuntime(const nsAString &aLanguageName,
-                                           nsIScriptRuntime **aLanguage)
-{
-  // Note that many callers have optimized detection for JS (along with
-  // supporting various alternate names for JS), so don't call this.
-  // One exception is for the new "script-type" attribute on a node - and
-  // there is no need to support backwards compatible names.
-  // As JS is the default language, this is still rarely called for JS -
-  // only when a node explicitly sets JS - so that is done last.
-  nsCAutoString contractid(NS_LITERAL_CSTRING(
-                          "@mozilla.org/script-language;1?script-type="));
-  // Arbitrarily use utf8 encoding should the name have extended chars
-  AppendUTF16toUTF8(aLanguageName, contractid);
-  nsresult rv;
-  nsCOMPtr<nsIScriptRuntime> lang =
-        do_GetService(contractid.get(), &rv);
-
-  if (NS_FAILED(rv)) {
-    if (aLanguageName.Equals(NS_LITERAL_STRING("application/javascript")))
-      return GetScriptRuntimeByID(nsIProgrammingLanguage::JAVASCRIPT, aLanguage);
-    // Not JS and nothing else we know about.
-    NS_WARNING("No script language registered for this mime-type");
-    return NS_ERROR_FACTORY_NOT_REGISTERED;
-  }
-  // And stash it away in our array for fast lookup by ID.
-  PRUint32 lang_ndx = NS_STID_INDEX(nsIProgrammingLanguage::JAVASCRIPT);
-  if (mLanguageArray[lang_ndx] == nsnull) {
-    mLanguageArray[lang_ndx] = lang;
-  } else {
-    // All languages are services - we should have an identical object!
-    NS_ASSERTION(mLanguageArray[lang_ndx] == lang,
-                 "Got a different language for this ID???");
-  }
-  *aLanguage = lang;
-  NS_IF_ADDREF(*aLanguage);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMScriptObjectFactory::GetScriptRuntimeByID(PRUint32 aLanguageID, 
-                                               nsIScriptRuntime **aLanguage)
-{
-  if (!NS_STID_VALID(aLanguageID)) {
-    NS_WARNING("Unknown script language");
-    return NS_ERROR_UNEXPECTED;
-  }
-  *aLanguage = mLanguageArray[NS_STID_INDEX(aLanguageID)];
-  if (!*aLanguage) {
-    nsCAutoString contractid(NS_LITERAL_CSTRING(
-                        "@mozilla.org/script-language;1?id="));
-    char langIdStr[25]; // space for an int.
-    sprintf(langIdStr, "%d", aLanguageID);
-    contractid += langIdStr;
-    nsresult rv;
-    nsCOMPtr<nsIScriptRuntime> lang = do_GetService(contractid.get(), &rv);
-
-    if (NS_FAILED(rv)) {
-      NS_ERROR("Failed to get the script language");
-      return rv;
-    }
-
-    // Stash it away in our array for fast lookup by ID.
-    mLanguageArray[NS_STID_INDEX(aLanguageID)] = lang;
-    *aLanguage = lang;
-  }
-  NS_IF_ADDREF(*aLanguage);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMScriptObjectFactory::GetIDForScriptType(const nsAString &aLanguageName,
-                                             PRUint32 *aScriptTypeID)
-{
-  nsCOMPtr<nsIScriptRuntime> languageRuntime;
-  nsresult rv;
-  rv = GetScriptRuntime(aLanguageName, getter_AddRefs(languageRuntime));
-  if (NS_FAILED(rv))
-    return rv;
-
-  *aScriptTypeID = nsIProgrammingLanguage::JAVASCRIPT;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMScriptObjectFactory::NewScriptGlobalObject(bool aIsChrome,
-                                                bool aIsModalContentWindow,
-                                                nsIScriptGlobalObject **aGlobal)
-{
-  return NS_NewScriptGlobalObject(aIsChrome, aIsModalContentWindow, aGlobal);
-}
-
 NS_IMETHODIMP_(nsISupports *)
 nsDOMScriptObjectFactory::GetClassInfoInstance(nsDOMClassInfoID aID)
 {
   return NS_GetDOMClassInfoInstance(aID);
 }
 
 NS_IMETHODIMP_(nsISupports *)
 nsDOMScriptObjectFactory::GetExternalClassInfoInstance(const nsAString& aName)
@@ -311,17 +195,17 @@ CreateXPConnectException(nsresult aResul
     exception = do_CreateInstance("@mozilla.org/js/xpc/Exception;1", &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = exception->Initialize(nsnull, aResult, nsnull, nsnull, nsnull,
                                nsnull);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  NS_ADDREF(*_retval = exception);
+  exception.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
 					       nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
 					       const nsIID *aProtoChainInterface,
 					       const nsIID **aInterfaces,
@@ -336,41 +220,52 @@ nsDOMScriptObjectFactory::RegisterDOMCla
                                              aConstructorFptr,
                                              aProtoChainInterface,
                                              aInterfaces,
                                              aScriptableFlags,
                                              aHasClassInterface,
                                              aConstructorCID);
 }
 
+
 // Factories
+static nsresult
+GetJSRuntime(nsIScriptRuntime** aLanguage)
+{
+  nsCOMPtr<nsIDOMScriptObjectFactory> factory =
+    do_GetService(kDOMScriptObjectFactoryCID);
+  NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
+
+  NS_IF_ADDREF(*aLanguage = factory->GetJSRuntime());
+  return NS_OK;
+}
+
 nsresult NS_GetScriptRuntime(const nsAString &aLanguageName,
                              nsIScriptRuntime **aLanguage)
 {
-  nsresult rv;
-  *aLanguage = nsnull;
-  nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
-        do_GetService(kDOMScriptObjectFactoryCID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
-  return factory->GetScriptRuntime(aLanguageName, aLanguage);
+  *aLanguage = NULL;
+
+  NS_ENSURE_TRUE(aLanguageName.EqualsLiteral("application/javascript"),
+                 NS_ERROR_FAILURE);
+
+  return GetJSRuntime(aLanguage);
 }
 
 nsresult NS_GetScriptRuntimeByID(PRUint32 aScriptTypeID,
                                  nsIScriptRuntime **aLanguage)
 {
-  nsresult rv;
-  *aLanguage = nsnull;
-  nsCOMPtr<nsIDOMScriptObjectFactory> factory = \
-        do_GetService(kDOMScriptObjectFactoryCID, &rv);
-  if (NS_FAILED(rv))
-    return rv;
-  return factory->GetScriptRuntimeByID(aScriptTypeID, aLanguage);
+  *aLanguage = NULL;
+
+  NS_ENSURE_TRUE(aScriptTypeID == nsIProgrammingLanguage::JAVASCRIPT,
+                 NS_ERROR_FAILURE);
+
+  return GetJSRuntime(aLanguage);
 }
 
+
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsDOMExceptionProvider, nsIExceptionProvider)
 
 NS_IMETHODIMP
 nsDOMExceptionProvider::GetException(nsresult result,
                                      nsIException *aDefaultException,
                                      nsIException **_retval)
 {
   if (!NS_IsMainThread()) {
--- a/dom/base/nsDOMScriptObjectFactory.h
+++ b/dom/base/nsDOMScriptObjectFactory.h
@@ -63,43 +63,26 @@ public:
   nsDOMScriptObjectFactory();
 
   NS_DECL_ISUPPORTS
 
   // nsIObserver
   NS_DECL_NSIOBSERVER
 
   // nsIDOMScriptObjectFactory
-  NS_IMETHOD GetScriptRuntime(const nsAString &aLanguageName,
-                              nsIScriptRuntime **aLanguage);
-
-  NS_IMETHOD GetScriptRuntimeByID(PRUint32 aLanguageID, 
-                                  nsIScriptRuntime **aLanguage);
-
-  NS_IMETHOD GetIDForScriptType(const nsAString &aLanguageName,
-                                PRUint32 *aLanguageID);
-
-  NS_IMETHOD NewScriptGlobalObject(bool aIsChrome,
-                                   bool aIsModalContentWindow,
-                                   nsIScriptGlobalObject **aGlobal);
-
   NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID);
   NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName);
 
   NS_IMETHOD RegisterDOMClassInfo(const char *aName,
                                   nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
                                   const nsIID *aProtoChainInterface,
                                   const nsIID **aInterfaces,
                                   PRUint32 aScriptableFlags,
                                   bool aHasClassInterface,
                                   const nsCID *aConstructorCID);
-
-protected:
-  bool mLoadedAllLanguages;
-  nsCOMPtr<nsIScriptRuntime> mLanguageArray[NS_STID_ARRAY_UBOUND];
 };
 
 class nsDOMExceptionProvider : public nsIExceptionProvider
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEXCEPTIONPROVIDER
 };
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10735,43 +10735,16 @@ nsGlobalModalWindow::SetNewDocument(nsID
 void
 nsGlobalWindow::SetHasAudioAvailableEventListeners()
 {
   if (mDoc) {
     mDoc->NotifyAudioAvailableListener();
   }
 }
 
-//*****************************************************************************
-// nsGlobalWindow: Creator Function (This should go away)
-//*****************************************************************************
-
-nsresult
-NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow,
-                         nsIScriptGlobalObject **aResult)
-{
-  *aResult = nsnull;
-
-  nsGlobalWindow *global;
-
-  if (aIsChrome) {
-    global = new nsGlobalChromeWindow(nsnull);
-  } else if (aIsModalContentWindow) {
-    global = new nsGlobalModalWindow(nsnull);
-  } else {
-    global = new nsGlobalWindow(nsnull);
-  }
-
-  NS_ENSURE_TRUE(global, NS_ERROR_OUT_OF_MEMORY);
-
-  NS_ADDREF(*aResult = global);
-
-  return NS_OK;
-}
-
 #define EVENT(name_, id_, type_, struct_)                                    \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
                                              jsval *vp) {                    \
     nsEventListenerManager *elm = GetListenerManager(false);              \
     if (elm) {                                                               \
       elm->GetJSEventListener(nsGkAtoms::on##name_, vp);                     \
     } else {                                                                 \
       *vp = JSVAL_NULL;                                                      \
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -1053,13 +1053,25 @@ public:
                                               nsISupports *aState,
                                               bool aForceReuseInnerWindow);
 
 protected:
   nsCOMPtr<nsIVariant> mReturnValue;
 };
 
 /* factory function */
-nsresult
-NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow,
-                         nsIScriptGlobalObject **aResult);
+inline already_AddRefed<nsGlobalWindow>
+NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow)
+{
+  nsRefPtr<nsGlobalWindow> global;
+
+  if (aIsChrome) {
+    global = new nsGlobalChromeWindow(nsnull);
+  } else if (aIsModalContentWindow) {
+    global = new nsGlobalModalWindow(nsnull);
+  } else {
+    global = new nsGlobalWindow(nsnull);
+  }
+
+  return global.forget();
+}
 
 #endif /* nsGlobalWindow_h___ */
--- a/dom/base/nsIDOMScriptObjectFactory.h
+++ b/dom/base/nsIDOMScriptObjectFactory.h
@@ -36,67 +36,54 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsIDOMScriptObjectFactory_h__
 #define nsIDOMScriptObjectFactory_h__
 
 #include "nsISupports.h"
 #include "nsIDOMClassInfo.h"
 #include "nsStringGlue.h"
+#include "nsIScriptRuntime.h"
 
-#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID   \
-{ 0x8c0eb687, 0xa859, 0x4a62, \
- { 0x99, 0x82, 0xea, 0xbf, 0x9e, 0xf5, 0x59, 0x5f } }
+#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
+{ 0x2a50e17c, 0x46ff, 0x4150, \
+  { 0xbb, 0x46, 0xd8, 0x07, 0xb3, 0x36, 0xde, 0xab } }
 
 class nsIScriptContext;
 class nsIScriptGlobalObject;
-class nsIScriptRuntime;
 class nsIDOMEventListener;
 
 typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
   (const char* aName);
 
 class nsIDOMScriptObjectFactory : public nsISupports {
 public:  
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
 
-  // Get a script language given its "name" (ie, the mime-type)
-  // Note that to fetch javascript from this function, you must currently
-  // use the name "application/javascript" (but also note that all existing
-  // callers of this function optimize the detection of JS, so do not
-  // ask this function for JS)
-  NS_IMETHOD GetScriptRuntime(const nsAString &aLanguageName,
-                              nsIScriptRuntime **aLanguage) = 0;
-
-  // Get a script language given its nsIProgrammingLanguage ID.
-  NS_IMETHOD GetScriptRuntimeByID(PRUint32 aScriptTypeID, 
-                                  nsIScriptRuntime **aLanguage) = 0;
-
-  // Get the ID for a language given its name - but like GetScriptRuntime,
-  // only "application/javascript" is currently supported for JS.
-  NS_IMETHOD GetIDForScriptType(const nsAString &aLanguageName,
-                                PRUint32 *aScriptTypeID) = 0;
-
-  NS_IMETHOD NewScriptGlobalObject(bool aIsChrome,
-                                   bool aIsModalContentWindow,
-                                   nsIScriptGlobalObject **aGlobal) = 0;
-
   NS_IMETHOD_(nsISupports *) GetClassInfoInstance(nsDOMClassInfoID aID) = 0;
   NS_IMETHOD_(nsISupports *) GetExternalClassInfoInstance(const nsAString& aName) = 0;
 
   // Register the info for an external class. aName must be static
   // data, it will not be deleted by the DOM code. aProtoChainInterface
   // must be registered in the JAVASCRIPT_DOM_INTERFACE category, or
   // prototypes for this class won't work (except if the interface
   // name starts with nsIDOM).
   NS_IMETHOD RegisterDOMClassInfo(const char *aName,
                                   nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
                                   const nsIID *aProtoChainInterface,
                                   const nsIID **aInterfaces,
                                   PRUint32 aScriptableFlags,
                                   bool aHasClassInterface,
                                   const nsCID *aConstructorCID) = 0;
+
+  nsIScriptRuntime* GetJSRuntime()
+  {
+    return mJSRuntime;
+  }
+
+protected:
+  nsCOMPtr<nsIScriptRuntime> mJSRuntime;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,
                               NS_IDOM_SCRIPT_OBJECT_FACTORY_IID)
 
 #endif /* nsIDOMScriptObjectFactory_h__ */