Fixing bug 105572. Don't bother GC'ing on context destruction when we're tearing down a frame in a frameset (or an iframe). r=jband@netscape.com, sr=vidur@netscape.com

This commit is contained in:
jst%netscape.com 2001-10-19 04:13:37 +00:00
Родитель 2ec931d14a
Коммит c5132891a9
4 изменённых файлов: 31 добавлений и 4 удалений

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

@ -326,6 +326,11 @@ public:
*/
NS_IMETHOD GetProcessingScriptTag(PRBool * aResult) =0;
NS_IMETHOD SetProcessingScriptTag(PRBool aResult) =0;
/**
* Tell the context whether or not to GC when destroyed.
*/
NS_IMETHOD SetGCOnDestruction(PRBool aGCOnDestruction) = 0;
};
#endif // nsIScriptContext_h__

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

@ -193,8 +193,6 @@ GlobalWindowImpl::~GlobalWindowImpl()
{
if (!--gRefCnt) {
NS_IF_RELEASE(gEntropyCollector);
NS_IF_RELEASE(sXPConnect);
}
mDocument = nsnull; // Forces Release
@ -278,6 +276,19 @@ NS_IMETHODIMP GlobalWindowImpl::SetContext(nsIScriptContext* aContext)
mContext = aContext;
if (mContext) {
nsCOMPtr<nsIDOMWindow> parent;
GetParent(getter_AddRefs(parent));
if (parent && parent != NS_STATIC_CAST(nsIDOMWindow *, this)) {
// 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.
mContext->SetGCOnDestruction(PR_FALSE);
}
}
return NS_OK;
}

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

@ -350,7 +350,7 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
return 0;
}
nsJSContext::nsJSContext(JSRuntime *aRuntime)
nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
{
NS_INIT_REFCNT();
@ -420,7 +420,7 @@ nsJSContext::~nsJSContext()
// Let xpconnect destroy the JSContext when it thinks the time is right.
nsCOMPtr<nsIXPConnect> xpc(do_GetService(nsIXPConnect::GetCID()));
if (xpc) {
xpc->ReleaseJSContext(mContext, PR_FALSE);
xpc->ReleaseJSContext(mContext, !mGCOnDestruction);
} else {
::JS_DestroyContext(mContext);
}
@ -1496,6 +1496,14 @@ nsJSContext::SetProcessingScriptTag(PRBool aFlag)
return NS_OK;
}
NS_IMETHODIMP
nsJSContext::SetGCOnDestruction(PRBool aGCOnDestruction)
{
mGCOnDestruction = aGCOnDestruction;
return NS_OK;
}
NS_IMETHODIMP
nsJSContext::ScriptExecuted()
{

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

@ -124,6 +124,8 @@ public:
NS_IMETHOD GetProcessingScriptTag(PRBool * aResult);
NS_IMETHOD SetProcessingScriptTag(PRBool aResult);
NS_IMETHOD SetGCOnDestruction(PRBool aGCOnDestruction);
NS_DECL_NSIXPCSCRIPTNOTIFY
protected:
nsresult InitClasses();
@ -142,6 +144,7 @@ private:
PRPackedBool mIsInitialized;
PRPackedBool mScriptsEnabled;
PRPackedBool mGCOnDestruction;
PRUint32 mBranchCallbackCount;
PRUint32 mDefaultJSOptions;