Bug 901106 - Remove nsIScriptRuntime. r=mrbkap

All this stuff is now for nsGlobalWindow's use only.
This commit is contained in:
Bobby Holley 2013-08-19 16:24:28 -07:00
Родитель ea43b1e71f
Коммит b4dde9a0ba
17 изменённых файлов: 14 добавлений и 122 удалений

Просмотреть файл

@ -34,7 +34,6 @@
#include "mozilla/css/ImageLoader.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsIScriptRuntime.h"
#include "nsCOMArray.h"
#include "nsDOMClassInfo.h"
#include "nsCxPusher.h"

Просмотреть файл

@ -19,7 +19,6 @@
#include "nsNetUtil.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIScriptRuntime.h"
#include "nsIScriptSecurityManager.h"
#include "nsIPrincipal.h"
#include "nsJSPrincipals.h"

Просмотреть файл

@ -20,7 +20,6 @@
#include "nsPIDOMWindow.h"
#include "nsIJSEventListener.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptRuntime.h"
#include "nsLayoutUtils.h"
#include "nsINameSpaceManager.h"
#include "nsIContent.h"

Просмотреть файл

@ -13,7 +13,6 @@
#include "nsIScriptObjectPrincipal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIScriptRuntime.h"
#include "nsIDOMScriptObjectFactory.h"
#include "jsapi.h"
#include "jsfriendapi.h"

Просмотреть файл

@ -46,7 +46,6 @@
#include "nsIRDFNode.h"
#include "nsIRDFService.h"
#include "nsIScriptContext.h"
#include "nsIScriptRuntime.h"
#include "nsIScriptSecurityManager.h"
#include "nsIServiceManager.h"
#include "mozilla/css/StyleRule.h"

Просмотреть файл

@ -65,7 +65,6 @@
#include "nsIObjectOutputStream.h"
#include "nsContentList.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptRuntime.h"
#include "nsIScriptSecurityManager.h"
#include "nsNodeInfoManager.h"
#include "nsContentCreatorFunctions.h"

Просмотреть файл

@ -30,7 +30,6 @@
#include "nsINodeInfo.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptRuntime.h"
#include "nsIServiceManager.h"
#include "nsIURL.h"
#include "nsParserBase.h"

Просмотреть файл

@ -8,7 +8,6 @@
#include "plstr.h"
#include "nsXULPrototypeDocument.h"
#include "nsCSSStyleSheet.h"
#include "nsIScriptRuntime.h"
#include "nsIServiceManager.h"
#include "nsIURI.h"

Просмотреть файл

@ -15,7 +15,6 @@
#include "nsIScriptGlobalObject.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIScriptSecurityManager.h"
#include "nsIScriptRuntime.h"
#include "nsIServiceManager.h"
#include "nsIArray.h"
#include "nsIURI.h"

Просмотреть файл

@ -37,7 +37,6 @@ EXPORTS += [
'nsIScriptGlobalObjectOwner.h',
'nsIScriptNameSpaceManager.h',
'nsIScriptObjectPrincipal.h',
'nsIScriptRuntime.h',
'nsIScriptTimeoutHandler.h',
'nsJSEnvironment.h',
'nsJSUtils.h',

Просмотреть файл

@ -31,8 +31,6 @@
#endif
#include "nsThreadUtils.h"
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
nsIExceptionProvider* gExceptionProvider = nullptr;
nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
@ -170,42 +168,6 @@ nsDOMScriptObjectFactory::RegisterDOMClassInfo(const char *aName,
aConstructorCID);
}
// Factories
nsresult
NS_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)
{
*aLanguage = NULL;
NS_ENSURE_TRUE(aLanguageName.EqualsLiteral("application/javascript"),
NS_ERROR_FAILURE);
return NS_GetJSRuntime(aLanguage);
}
nsresult NS_GetScriptRuntimeByID(uint32_t aScriptTypeID,
nsIScriptRuntime **aLanguage)
{
*aLanguage = NULL;
NS_ENSURE_TRUE(aScriptTypeID == nsIProgrammingLanguage::JAVASCRIPT,
NS_ERROR_FAILURE);
return NS_GetJSRuntime(aLanguage);
}
NS_IMPL_ISUPPORTS1(nsDOMExceptionProvider, nsIExceptionProvider)
NS_IMETHODIMP

Просмотреть файл

@ -156,7 +156,6 @@
#include "nsWindowRoot.h"
#include "nsNetCID.h"
#include "nsIArray.h"
#include "nsIScriptRuntime.h"
// XXX An unfortunate dependency exists here (two XUL files).
#include "nsIDOMXULDocument.h"
@ -1774,6 +1773,8 @@ nsGlobalWindow::UnmarkGrayTimers()
// nsGlobalWindow::nsIScriptGlobalObject
//*****************************************************************************
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
nsresult
nsGlobalWindow::EnsureScriptEnvironment()
{
@ -1786,22 +1787,22 @@ nsGlobalWindow::EnsureScriptEnvironment()
NS_ASSERTION(!GetCurrentInnerWindowInternal(),
"mJSObject is null, but we have an inner window?");
nsCOMPtr<nsIScriptRuntime> scriptRuntime;
nsresult rv = NS_GetJSRuntime(getter_AddRefs(scriptRuntime));
NS_ENSURE_SUCCESS(rv, rv);
// NB: The existing ownership model requires us to get the script object
// factory before we can access the nsJSRuntime. This will go away shortly.
nsCOMPtr<nsIDOMScriptObjectFactory> factory = do_GetService(kDOMScriptObjectFactoryCID);
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
// If this window is a [i]frame, don't bother GC'ing when the frame's context
// is destroyed since a GC will happen when the frameset or host document is
// destroyed anyway.
nsCOMPtr<nsIScriptContext> context =
scriptRuntime->CreateContext(!IsFrame(), this);
nsCOMPtr<nsIScriptContext> context = new nsJSContext(nsJSRuntime::sRuntime, !IsFrame(), this);
NS_ASSERTION(!mContext, "Will overwrite mContext!");
// should probably assert the context is clean???
context->WillInitializeContext();
rv = context->InitContext();
nsresult rv = context->InitContext();
NS_ENSURE_SUCCESS(rv, rv);
mContext = context;

Просмотреть файл

@ -9,7 +9,6 @@
#include "nsISupports.h"
#include "nsIDOMClassInfo.h"
#include "nsStringGlue.h"
#include "nsIScriptRuntime.h"
#define NS_IDOM_SCRIPT_OBJECT_FACTORY_IID \
{ 0x2a50e17c, 0x46ff, 0x4150, \
@ -18,6 +17,7 @@
class nsIScriptContext;
class nsIScriptGlobalObject;
class nsIDOMEventListener;
class nsJSRuntime;
typedef nsXPCClassInfo* (*nsDOMClassInfoExternalConstructorFnc)
(const char* aName);
@ -42,13 +42,8 @@ public:
bool aHasClassInterface,
const nsCID *aConstructorCID) = 0;
nsIScriptRuntime* GetJSRuntime()
{
return mJSRuntime;
}
protected:
nsCOMPtr<nsIScriptRuntime> mJSRuntime;
nsRefPtr<nsJSRuntime> mJSRuntime;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDOMScriptObjectFactory,

Просмотреть файл

@ -1,41 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsIScriptRuntime_h__
#define nsIScriptRuntime_h__
#include "nsIScriptContext.h"
#define NS_ISCRIPTRUNTIME_IID \
{ 0x86c6b54a, 0xf067, 0x4878, \
{ 0xb2, 0x77, 0x4e, 0xee, 0x95, 0xda, 0x8f, 0x76 } }
/**
* A singleton language environment for an application. Responsible for
* initializing and cleaning up the global language environment, and a factory
* for language contexts
*/
class nsIScriptRuntime : public nsISupports
{
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTRUNTIME_IID)
/* Factory for a new context for this language */
virtual already_AddRefed<nsIScriptContext>
CreateContext(bool aGCOnDestruction,
nsIScriptGlobalObject* aGlobalObject) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptRuntime, NS_ISCRIPTRUNTIME_IID)
/* helper functions */
nsresult NS_GetJSRuntime(nsIScriptRuntime** aLanguage);
nsresult NS_GetScriptRuntime(const nsAString &aLanguageName,
nsIScriptRuntime **aRuntime);
nsresult NS_GetScriptRuntimeByID(uint32_t aLanguageID,
nsIScriptRuntime **aRuntime);
#endif // nsIScriptRuntime_h__

Просмотреть файл

@ -2567,22 +2567,13 @@ nsJSContext::LikelyShortLivingObjectCreated()
// QueryInterface implementation for nsJSRuntime
NS_INTERFACE_MAP_BEGIN(nsJSRuntime)
NS_INTERFACE_MAP_ENTRY(nsIScriptRuntime)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsJSRuntime)
NS_IMPL_RELEASE(nsJSRuntime)
already_AddRefed<nsIScriptContext>
nsJSRuntime::CreateContext(bool aGCOnDestruction,
nsIScriptGlobalObject* aGlobalObject)
{
nsCOMPtr<nsIScriptContext> scriptContext =
new nsJSContext(sRuntime, aGCOnDestruction, aGlobalObject);
return scriptContext.forget();
}
//static
void
nsJSRuntime::Startup()
@ -2910,7 +2901,7 @@ nsJSRuntime::Shutdown()
}
// A factory for the runtime.
nsresult NS_CreateJSRuntime(nsIScriptRuntime **aRuntime)
nsresult NS_CreateJSRuntime(nsJSRuntime **aRuntime)
{
nsresult rv = nsJSRuntime::Init();
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -6,7 +6,6 @@
#define nsJSEnvironment_h
#include "nsIScriptContext.h"
#include "nsIScriptRuntime.h"
#include "nsIScriptGlobalObject.h"
#include "nsCOMPtr.h"
#include "jsapi.h"
@ -183,7 +182,7 @@ private:
class nsIJSRuntimeService;
class nsJSRuntime MOZ_FINAL : public nsIScriptRuntime
class nsJSRuntime MOZ_FINAL : public nsISupports
{
public:
// let people who can see us use our runtime for convenience.
@ -193,10 +192,6 @@ public:
// nsISupports
NS_DECL_ISUPPORTS
virtual already_AddRefed<nsIScriptContext>
CreateContext(bool aGCOnDestruction,
nsIScriptGlobalObject* aGlobalObject) MOZ_OVERRIDE;
static void Startup();
static void Shutdown();
// Setup all the statics etc - safe to call multiple times after Startup()
@ -226,7 +221,7 @@ public:
NS_DEFINE_STATIC_IID_ACCESSOR(nsIJSArgArray, NS_IJSARGARRAY_IID)
/* factory functions */
nsresult NS_CreateJSRuntime(nsIScriptRuntime **aRuntime);
nsresult NS_CreateJSRuntime(nsJSRuntime **aRuntime);
/* prototypes */
void NS_ScriptErrorReporter(JSContext *cx, const char *message, JSErrorReport *report);

Просмотреть файл

@ -9,7 +9,6 @@
#include "nsIScriptSecurityManager.h"
#include "nsIScriptContext.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptRuntime.h"
#include "nsIXPConnect.h"
#include "nsGUIEvent.h"
#include "nsContentUtils.h"