Bug 694769 - Remove nsIScriptContext::GetScriptGlobal in favour of GetGlobalJSObject; r=smaug
This commit is contained in:
@@ -899,8 +899,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
|||||||
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, uri, url);
|
nsContentUtils::GetWrapperSafeScriptFilename(mDocument, uri, url);
|
||||||
|
|
||||||
bool isUndefined;
|
bool isUndefined;
|
||||||
rv = context->EvaluateString(aScript,
|
rv = context->EvaluateString(aScript, globalObject->GetGlobalJSObject(),
|
||||||
globalObject->GetScriptGlobal(stid),
|
|
||||||
mDocument->NodePrincipal(), url.get(),
|
mDocument->NodePrincipal(), url.get(),
|
||||||
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
|
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
|
||||||
&isUndefined);
|
&isUndefined);
|
||||||
|
|||||||
@@ -442,7 +442,6 @@ nsEventListenerManager::AddScriptEventListener(nsIAtom *aName,
|
|||||||
{
|
{
|
||||||
NS_PRECONDITION(aLanguage != nsIProgrammingLanguage::UNKNOWN,
|
NS_PRECONDITION(aLanguage != nsIProgrammingLanguage::UNKNOWN,
|
||||||
"Must know the language for the script event listener");
|
"Must know the language for the script event listener");
|
||||||
nsIScriptContext *context = nsnull;
|
|
||||||
|
|
||||||
// |aPermitUntrustedEvents| is set to False for chrome - events
|
// |aPermitUntrustedEvents| is set to False for chrome - events
|
||||||
// *generated* from an unknown source are not allowed.
|
// *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.
|
// 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);
|
NS_ENSURE_TRUE(context, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
void *scope = global->GetScriptGlobal(aLanguage);
|
JSObject* scope = global->GetGlobalJSObject();
|
||||||
|
|
||||||
nsListenerStruct *ls;
|
nsListenerStruct *ls;
|
||||||
rv = SetJSEventListener(context, scope, aName, nsnull,
|
rv = SetJSEventListener(context, scope, aName, nsnull,
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ protected:
|
|||||||
|
|
||||||
void SetContext(nsIScriptContext *aContext);
|
void SetContext(nsIScriptContext *aContext);
|
||||||
nsIScriptContext *GetScriptContext(PRUint32 language);
|
nsIScriptContext *GetScriptContext(PRUint32 language);
|
||||||
void *GetScriptGlobal(PRUint32 language);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIScriptContext> mScriptContext;
|
nsCOMPtr<nsIScriptContext> mScriptContext;
|
||||||
JSObject *mJSObject; // XXX JS language rabies bigotry badness
|
JSObject *mJSObject; // XXX JS language rabies bigotry badness
|
||||||
@@ -289,14 +288,6 @@ nsXBLDocGlobalObject::GetScriptContext(PRUint32 language)
|
|||||||
return GetContext();
|
return GetContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
nsXBLDocGlobalObject::GetScriptGlobal(PRUint32 language)
|
|
||||||
{
|
|
||||||
// This impl still assumes JS
|
|
||||||
NS_ENSURE_TRUE(language==nsIProgrammingLanguage::JAVASCRIPT, nsnull);
|
|
||||||
return GetGlobalJSObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsXBLDocGlobalObject::EnsureScriptEnvironment(PRUint32 aLangID)
|
nsXBLDocGlobalObject::EnsureScriptEnvironment(PRUint32 aLangID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -265,9 +265,6 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
|
|||||||
nsCOMPtr<nsIAtom> onEventAtom = do_GetAtom(NS_LITERAL_STRING("onxbl") +
|
nsCOMPtr<nsIAtom> onEventAtom = do_GetAtom(NS_LITERAL_STRING("onxbl") +
|
||||||
nsDependentAtomString(mEventName));
|
nsDependentAtomString(mEventName));
|
||||||
|
|
||||||
// Compile the event handler.
|
|
||||||
PRUint32 stID = nsIProgrammingLanguage::JAVASCRIPT;
|
|
||||||
|
|
||||||
// Compile the handler and bind it to the element.
|
// Compile the handler and bind it to the element.
|
||||||
nsCOMPtr<nsIScriptGlobalObject> boundGlobal;
|
nsCOMPtr<nsIScriptGlobalObject> boundGlobal;
|
||||||
nsCOMPtr<nsPIWindowRoot> winRoot(do_QueryInterface(aTarget));
|
nsCOMPtr<nsPIWindowRoot> winRoot(do_QueryInterface(aTarget));
|
||||||
@@ -301,7 +298,8 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
|
|||||||
if (!boundGlobal)
|
if (!boundGlobal)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
nsIScriptContext *boundContext = boundGlobal->GetScriptContext(stID);
|
nsIScriptContext *boundContext =
|
||||||
|
boundGlobal->GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
|
||||||
if (!boundContext)
|
if (!boundContext)
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|
||||||
@@ -318,7 +316,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventTarget* aTarget,
|
|||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Bind it to the bound element
|
// Bind it to the bound element
|
||||||
void *scope = boundGlobal->GetScriptGlobal(stID);
|
JSObject* scope = boundGlobal->GetGlobalJSObject();
|
||||||
nsScriptObjectHolder boundHandler(boundContext);
|
nsScriptObjectHolder boundHandler(boundContext);
|
||||||
rv = boundContext->BindCompiledEventHandler(scriptTarget, scope,
|
rv = boundContext->BindCompiledEventHandler(scriptTarget, scope,
|
||||||
handler, boundHandler);
|
handler, boundHandler);
|
||||||
|
|||||||
@@ -3631,15 +3631,11 @@ nsXULDocument::ExecuteScript(nsIScriptContext * aContext, void * aScriptObject)
|
|||||||
|
|
||||||
NS_ENSURE_TRUE(mScriptGlobalObject, NS_ERROR_NOT_INITIALIZED);
|
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
|
// Execute the precompiled script with the given version
|
||||||
nsresult rv;
|
JSObject* global = mScriptGlobalObject->GetGlobalJSObject();
|
||||||
void *global = mScriptGlobalObject->GetScriptGlobal(
|
return aContext->ExecuteScript(aScriptObject, global, nsnull, nsnull);
|
||||||
aContext->GetScriptTypeID());
|
|
||||||
rv = aContext->ExecuteScript(aScriptObject,
|
|
||||||
global,
|
|
||||||
nsnull, nsnull);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
virtual void OnFinalize(JSObject* aObject);
|
virtual void OnFinalize(JSObject* aObject);
|
||||||
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
|
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
|
||||||
|
|
||||||
virtual void *GetScriptGlobal(PRUint32 lang);
|
virtual JSObject* GetGlobalJSObject();
|
||||||
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
|
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
|
||||||
|
|
||||||
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
|
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
|
||||||
@@ -769,11 +769,9 @@ nsXULPDGlobalObject::GetScriptContext(PRUint32 lang_id)
|
|||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
JSObject*
|
||||||
nsXULPDGlobalObject::GetScriptGlobal(PRUint32 lang_id)
|
nsXULPDGlobalObject::GetGlobalJSObject()
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(lang_id == nsIProgrammingLanguage::JAVASCRIPT,
|
|
||||||
"We don't support this language ID");
|
|
||||||
return mJSObject;
|
return mJSObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1575,14 +1575,6 @@ nsGlobalWindow::GetScriptContext(PRUint32 lang)
|
|||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
|
||||||
nsGlobalWindow::GetScriptGlobal(PRUint32 lang)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(lang == nsIProgrammingLanguage::JAVASCRIPT,
|
|
||||||
"We don't support this language ID");
|
|
||||||
return mJSObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIScriptContext *
|
nsIScriptContext *
|
||||||
nsGlobalWindow::GetContext()
|
nsGlobalWindow::GetContext()
|
||||||
{
|
{
|
||||||
@@ -1597,8 +1589,6 @@ nsGlobalWindow::GetContext()
|
|||||||
JSObject *
|
JSObject *
|
||||||
nsGlobalWindow::GetGlobalJSObject()
|
nsGlobalWindow::GetGlobalJSObject()
|
||||||
{
|
{
|
||||||
NS_ASSERTION(mJSObject == GetScriptGlobal(nsIProgrammingLanguage::JAVASCRIPT),
|
|
||||||
"GetGlobalJSObject confused?");
|
|
||||||
return FastGetGlobalJSObject();
|
return FastGetGlobalJSObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9304,8 +9294,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
|
|||||||
NS_TIME_FUNCTION_MARK("(file: %s, line: %d)", filename, lineNo);
|
NS_TIME_FUNCTION_MARK("(file: %s, line: %d)", filename, lineNo);
|
||||||
|
|
||||||
bool is_undefined;
|
bool is_undefined;
|
||||||
scx->EvaluateString(nsDependentString(script),
|
scx->EvaluateString(nsDependentString(script), FastGetGlobalJSObject(),
|
||||||
GetScriptGlobal(handler->GetScriptTypeID()),
|
|
||||||
timeout->mPrincipal, filename, lineNo,
|
timeout->mPrincipal, filename, lineNo,
|
||||||
handler->GetScriptVersion(), nsnull,
|
handler->GetScriptVersion(), nsnull,
|
||||||
&is_undefined);
|
&is_undefined);
|
||||||
@@ -9318,8 +9307,7 @@ nsGlobalWindow::RunTimeout(nsTimeout *aTimeout)
|
|||||||
|
|
||||||
nsCOMPtr<nsIVariant> dummy;
|
nsCOMPtr<nsIVariant> dummy;
|
||||||
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));
|
nsCOMPtr<nsISupports> me(static_cast<nsIDOMWindow *>(this));
|
||||||
scx->CallEventHandler(me,
|
scx->CallEventHandler(me, FastGetGlobalJSObject(),
|
||||||
GetScriptGlobal(handler->GetScriptTypeID()),
|
|
||||||
scriptObject, handler->GetArgv(),
|
scriptObject, handler->GetArgv(),
|
||||||
// XXXmarkh - consider allowing CallEventHandler to
|
// XXXmarkh - consider allowing CallEventHandler to
|
||||||
// accept nsnull?
|
// accept nsnull?
|
||||||
|
|||||||
@@ -321,7 +321,6 @@ public:
|
|||||||
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
|
virtual nsresult EnsureScriptEnvironment(PRUint32 aLangID);
|
||||||
|
|
||||||
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
|
virtual nsIScriptContext *GetScriptContext(PRUint32 lang);
|
||||||
virtual void *GetScriptGlobal(PRUint32 lang);
|
|
||||||
|
|
||||||
// Set a new script language context for this global. The native global
|
// Set a new script language context for this global. The native global
|
||||||
// for the context is created by the context's GetNativeGlobal() method.
|
// for the context is created by the context's GetNativeGlobal() method.
|
||||||
|
|||||||
@@ -100,8 +100,8 @@ NS_HandleScriptError(nsIScriptGlobalObject *aScriptGlobal,
|
|||||||
|
|
||||||
|
|
||||||
#define NS_ISCRIPTGLOBALOBJECT_IID \
|
#define NS_ISCRIPTGLOBALOBJECT_IID \
|
||||||
{ 0x4eb16819, 0x4e81, 0x406e, \
|
{ 0x08f73284, 0x26e3, 0x4fa6, \
|
||||||
{ 0x93, 0x05, 0x6f, 0x30, 0xfc, 0xd2, 0x62, 0x4a } }
|
{ 0xbf, 0x89, 0x83, 0x26, 0xf9, 0x2a, 0x94, 0xb3 } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The global object which keeps a script context for each supported script
|
* The global object which keeps a script context for each supported script
|
||||||
@@ -128,15 +128,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual nsIScriptContext *GetScriptContext(PRUint32 lang) = 0;
|
virtual nsIScriptContext *GetScriptContext(PRUint32 lang) = 0;
|
||||||
|
|
||||||
/**
|
virtual JSObject* GetGlobalJSObject() = 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 nsIScriptContext *GetContext() {
|
virtual nsIScriptContext *GetContext() {
|
||||||
return GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
|
return GetScriptContext(nsIProgrammingLanguage::JAVASCRIPT);
|
||||||
|
|||||||
@@ -2244,7 +2244,7 @@ nsJSContext::ConnectToInner(nsIScriptGlobalObject *aNewInner, void *aOuterGlobal
|
|||||||
{
|
{
|
||||||
NS_ENSURE_ARG(aNewInner);
|
NS_ENSURE_ARG(aNewInner);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
JSObject *newInnerJSObject = (JSObject *)aNewInner->GetScriptGlobal(JAVASCRIPT);
|
JSObject *newInnerJSObject = aNewInner->GetGlobalJSObject();
|
||||||
#endif
|
#endif
|
||||||
JSObject *outerGlobal = (JSObject *)aOuterGlobal;
|
JSObject *outerGlobal = (JSObject *)aOuterGlobal;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user