Bug 694769 - Remove nsIScriptContext::GetScriptGlobal in favour of GetGlobalJSObject; r=smaug

This commit is contained in:
Ms2ger 2011-10-29 22:09:04 +02:00
Родитель d804dd409b
Коммит a8dba5714a
10 изменённых файлов: 19 добавлений и 59 удалений

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

@ -899,8 +899,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, uri, url);
bool isUndefined;
rv = context->EvaluateString(aScript,
globalObject->GetScriptGlobal(stid),
rv = context->EvaluateString(aScript, globalObject->GetGlobalJSObject(),
mDocument->NodePrincipal(), url.get(),
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
&isUndefined);

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

@ -442,7 +442,6 @@ nsEventListenerManager::AddScriptEventListener(nsIAtom *aName,
{
NS_PRECONDITION(aLanguage != nsIProgrammingLanguage::UNKNOWN,
"Must know the language for the script event listener");
nsIScriptContext *context = nsnull;
// |aPermitUntrustedEvents| is set to False for chrome - events
// *generated* from an unknown source are not allowed.
@ -532,10 +531,10 @@ nsEventListenerManager::AddScriptEventListener(nsIAtom *aName,
// but fall through and let the inevitable failure below handle it.
}
context = global->GetScriptContext(aLanguage);
nsIScriptContext* context = global->GetScriptContext(aLanguage);
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
void *scope = global->GetScriptGlobal(aLanguage);
JSObject* scope = global->GetGlobalJSObject();
nsListenerStruct *ls;
rv = SetJSEventListener(context, scope, aName, nsnull,

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

@ -95,7 +95,6 @@ protected:
void SetContext(nsIScriptContext *aContext);
nsIScriptContext *GetScriptContext(PRUint32 language);
void *GetScriptGlobal(PRUint32 language);
nsCOMPtr<nsIScriptContext> mScriptContext;
JSObject *mJSObject; // XXX JS language rabies bigotry badness
@ -289,14 +288,6 @@ nsXBLDocGlobalObject::GetScriptContext(PRUint32 language)
return GetContext();
}
void *
nsXBLDocGlobalObject::GetScriptGlobal(PRUint32 language)
{
// This impl still assumes JS
NS_ENSURE_TRUE(language==nsIProgrammingLanguage::JAVASCRIPT, nsnull);
return GetGlobalJSObject();
}
nsresult
nsXBLDocGlobalObject::EnsureScriptEnvironment(PRUint32 aLangID)
{

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

@ -265,9 +265,6 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
nsCOMPtr<nsIAtom> onEventAtom = do_GetAtom(NS_LITERAL_STRING("onxbl") +
nsDependentAtomString(mEventName));
// Compile the event handler.
PRUint32 stID = nsIProgrammingLanguage::JAVASCRIPT;
// Compile the handler and bind it to the element.
nsCOMPtr<nsIScriptGlobalObject> boundGlobal;
nsCOMPtr<nsPIWindowRoot> winRoot(do_QueryInterface(aTarget));
@ -301,7 +298,8 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
if (!boundGlobal)
return NS_OK;
nsIScriptContext *boundContext = boundGlobal->GetScriptContext(stID);
nsIScriptContext *boundContext =
boundGlobal->GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
if (!boundContext)
return NS_OK;
@ -318,7 +316,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
NS_ENSURE_SUCCESS(rv, rv);
// Bind it to the bound element
void *scope = boundGlobal->GetScriptGlobal(stID);
JSObject* scope = boundGlobal->GetGlobalJSObject();
nsScriptObjectHolder boundHandler(boundContext);
rv = boundContext->BindCompiledEventHandler(scriptTarget, scope,
handler, boundHandler);

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

@ -3631,15 +3631,11 @@ nsXULDocument::ExecuteScript(nsIScriptContext * aContext, void * aScriptObject)
NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
NS_ABORT_IF_FALSE(aContext->GetScriptTypeID() == nsIProgrammingLanguage::JAVASCRIPT,
"Should have a JavaScript nsIScriptContext.");
// Execute the precompiled script with the given version
nsresult rv;
void *global = mScriptGlobalObject->GetScriptGlobal(
aContext->GetScriptTypeID());
rv = aContext->ExecuteScript(aScriptObject,
global,
nsnull, nsnull);
return rv;
JSObject* global = mScriptGlobalObject->GetGlobalJSObject();
return aContext->ExecuteScript(aScriptObject, global, nsnull, nsnull);
}
nsresult

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

@ -84,7 +84,7 @@ public:
virtual void OnFinalize(JSObject* aObject);
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
virtual void *GetScriptGlobal(PRUint32 lang);
virtual JSObject* GetGlobalJSObject();
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
@ -769,11 +769,9 @@ nsXULPDGlobalObject::GetScriptContext(PRUint32 lang_id)
return mContext;
}
void*
nsXULPDGlobalObject::GetScriptGlobal(PRUint32 lang_id)
JSObject*
nsXULPDGlobalObject::GetGlobalJSObject()
{
NS_ABORT_IF_FALSE(lang_id == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
return mJSObject;
}

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

@ -1575,14 +1575,6 @@ nsGlobalWindow::GetScriptContext(PRUint32 lang)
return mContext;
}
void *
nsGlobalWindow::GetScriptGlobal(PRUint32 lang)
{
NS_ASSERTION(lang == nsIProgrammingLanguage::JAVASCRIPT,
"We don't support this language ID");
return mJSObject;
}
nsIScriptContext *
nsGlobalWindow::GetContext()
{
@ -1597,8 +1589,6 @@ nsGlobalWindow::GetContext()
JSObject *
nsGlobalWindow::GetGlobalJSObject()
{
NS_ASSERTION(mJSObject == GetScriptGlobal(nsIProgrammingLanguage::JAVASCRIPT),
"GetGlobalJSObject confused?");
return FastGetGlobalJSObject();
}
@ -9304,8 +9294,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
NS_TIME_FUNCTION_MARK("(file: %s, line: %d)", filename, lineNo);
bool is_undefined;
scx->EvaluateString(nsDependentString(script),
GetScriptGlobal(handler->GetScriptTypeID()),
scx->EvaluateString(nsDependentString(script), FastGetGlobalJSObject(),
timeout->mPrincipal, filename, lineNo,
handler->GetScriptVersion(), nsnull,
&is_undefined);
@ -9318,8 +9307,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
nsCOMPtr<nsIVariant> dummy;
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));
scx->CallEventHandler(me,
GetScriptGlobal(handler->GetScriptTypeID()),
scx->CallEventHandler(me, FastGetGlobalJSObject(),
scriptObject, handler->GetArgv(),
// XXXmarkh - consider allowing CallEventHandler to
// accept nsnull?

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

@ -321,7 +321,6 @@ public:
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
virtual void *GetScriptGlobal(PRUint32 lang);
// Set a new script language context for this global. The native global
// for the context is created by the context's GetNativeGlobal() method.

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

@ -100,8 +100,8 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
#define NS_ISCRIPTGLOBALOBJECT_IID \
{ 0x4eb16819, 0x4e81, 0x406e, \
{ 0x93, 0x05, 0x6f, 0x30, 0xfc, 0xd2, 0x62, 0x4a } }
{ 0x08f73284, 0x26e3, 0x4fa6, \
{ 0xbf, 0x89, 0x83, 0x26, 0xf9, 0x2a, 0x94, 0xb3 } }
/**
* The global object which keeps a script context for each supported script
@ -128,15 +128,7 @@ public:
*/
virtual nsIScriptContext *GetScriptContext(PRUint32 lang) = 0;
/**
* Get the opaque "global" object for the specified lang.
*/
virtual void *GetScriptGlobal(PRUint32 lang) = 0;
// Set/GetContext deprecated methods - use GetScriptContext/Global
virtual JSObject *GetGlobalJSObject() {
return (JSObject *)GetScriptGlobal(nsIProgrammingLanguage::JAVASCRIPT);
}
virtual JSObject* GetGlobalJSObject() = 0;
virtual nsIScriptContext *GetContext() {
return GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);

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

@ -2244,7 +2244,7 @@ nsJSContext::ConnectToInner(nsIScriptGlobalObject *aNewInner, void *aOuterGlobal
{
NS_ENSURE_ARG(aNewInner);
#ifdef DEBUG
JSObject *newInnerJSObject = (JSObject *)aNewInner->GetScriptGlobal(JAVASCRIPT);
JSObject *newInnerJSObject = aNewInner->GetGlobalJSObject();
#endif
JSObject *outerGlobal = (JSObject *)aOuterGlobal;