зеркало из https://github.com/mozilla/gecko-dev.git
Fixing part of bug 111213. Make nsIScriptContext::SetScriptsEnabled() 'restart' scripts if they were turned off earlier in this context (print preview relies on this). r=jkeiser@iname.com, sr=jband@netscape.com
This commit is contained in:
Родитель
c49b6b3eb3
Коммит
e89c147731
|
@ -41,6 +41,7 @@ public:
|
|||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD_(JSObject *) GetGlobalJSObject();
|
||||
NS_IMETHOD OnFinalize(JSObject *aObject);
|
||||
NS_IMETHOD SetScriptsEnabled(PRBool aEnabled);
|
||||
|
||||
// nsIScriptObjectPrincipal methods
|
||||
NS_IMETHOD GetPrincipal(nsIPrincipal** aPrincipal);
|
||||
|
@ -237,6 +238,15 @@ nsXBLDocGlobalObject::OnFinalize(JSObject *aObject)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXBLDocGlobalObject::SetScriptsEnabled(PRBool aEnabled)
|
||||
{
|
||||
// We don't care...
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIScriptObjectPrincipal methods
|
||||
|
|
|
@ -98,6 +98,7 @@ public:
|
|||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD_(JSObject *) GetGlobalJSObject();
|
||||
NS_IMETHOD OnFinalize(JSObject *aObject);
|
||||
NS_IMETHOD SetScriptsEnabled(PRBool aEnabled);
|
||||
|
||||
// nsIScriptObjectPrincipal methods
|
||||
NS_IMETHOD GetPrincipal(nsIPrincipal** aPrincipal);
|
||||
|
@ -725,6 +726,15 @@ nsXULPDGlobalObject::OnFinalize(JSObject *aObject)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULPDGlobalObject::SetScriptsEnabled(PRBool aEnabled)
|
||||
{
|
||||
// We don't care...
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
//
|
||||
// nsIScriptObjectPrincipal methods
|
||||
|
|
|
@ -101,6 +101,11 @@ public:
|
|||
*/
|
||||
|
||||
NS_IMETHOD OnFinalize(JSObject *aJSObject) = 0;
|
||||
|
||||
/**
|
||||
* Called when scripts are enabled/disabled.
|
||||
*/
|
||||
NS_IMETHOD SetScriptsEnabled(PRBool aEnabled) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -698,6 +698,19 @@ GlobalWindowImpl::OnFinalize(JSObject *aJSObject)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
GlobalWindowImpl::SetScriptsEnabled(PRBool aEnabled)
|
||||
{
|
||||
if (aEnabled) {
|
||||
// Scripts are enabled (again?) on this context, run timeouts that
|
||||
// fired on this context while scripts were disabled.
|
||||
|
||||
RunTimeout(nsnull);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
// GlobalWindowImpl::nsIScriptObjectPrincipal
|
||||
|
@ -3664,6 +3677,22 @@ GlobalWindowImpl::SetTimeoutOrInterval(PRBool aIsInterval, PRInt32 *aReturn)
|
|||
|
||||
void GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
||||
{
|
||||
PRBool scripts_enabled = PR_TRUE;
|
||||
|
||||
mContext->GetScriptsEnabled(&scripts_enabled);
|
||||
|
||||
if (!scripts_enabled) {
|
||||
// Scripts were enabled once in this window (unless aTimeout ==
|
||||
// nsnull) but now scripts are disabled (we might be in
|
||||
// print-preview, for instance), this means we shouldn't run any
|
||||
// timeouts at this point.
|
||||
//
|
||||
// If scrips are enabled in this window again we'll fire the
|
||||
// timeouts that are due at that point.
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
nsTimeoutImpl *next, *prev, *timeout;
|
||||
nsTimeoutImpl *last_expired_timeout, **last_insertion_point;
|
||||
nsTimeoutImpl dummy_timeout;
|
||||
|
@ -3687,7 +3716,7 @@ void GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
// servicing
|
||||
LL_I2L(now, PR_IntervalNow());
|
||||
|
||||
if (LL_CMP(aTimeout->when, >, now)) {
|
||||
if (aTimeout && LL_CMP(aTimeout->when, >, now)) {
|
||||
// The OS timer fired early (yikes!), and possibly out of order
|
||||
// too. Set |deadline| to be the time when the OS timer *should*
|
||||
// have fired so that any timers that *should* have fired before
|
||||
|
|
|
@ -137,6 +137,7 @@ public:
|
|||
nsEventStatus* aEventStatus);
|
||||
NS_IMETHOD_(JSObject *) GetGlobalJSObject();
|
||||
NS_IMETHOD OnFinalize(JSObject *aJSObject);
|
||||
NS_IMETHOD SetScriptsEnabled(PRBool aEnabled);
|
||||
|
||||
// nsIScriptObjectPrincipal
|
||||
NS_IMETHOD GetPrincipal(nsIPrincipal **prin);
|
||||
|
|
|
@ -1492,6 +1492,14 @@ NS_IMETHODIMP
|
|||
nsJSContext::SetScriptsEnabled(PRBool aEnabled)
|
||||
{
|
||||
mScriptsEnabled = aEnabled;
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> global;
|
||||
GetGlobalObject(getter_AddRefs(global));
|
||||
|
||||
if (global) {
|
||||
global->SetScriptsEnabled(aEnabled);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче