if (nsnull != mScriptGlobal) { mScriptGlobal->SetWebShell(nsnull); NS_RELEASE(mScriptGlobal);
if (mScriptGlobal) { mScriptGlobal->SetDocShell(nsnull); mScriptGlobal = nsnull;
nsWebShell::~nsWebShell(){  // Stop any pending document loads and destroy the loader...  if (nsnull != mDocLoader) {    mDocLoader->Stop();    mDocLoader->RemoveObserver((nsIDocumentLoaderObserver*)this);    mDocLoader->SetContainer(nsnull);    NS_RELEASE(mDocLoader);  }  // Cancel any timers that were set for this loader.  CancelRefreshURLTimers();  NS_IF_RELEASE(mWindow);  NS_IF_RELEASE(mContentViewer);  NS_IF_RELEASE(mDeviceContext);  NS_IF_RELEASE(mPrefs);  NS_IF_RELEASE(mURLListener);  NS_IF_RELEASE(mContainer);  NS_IF_RELEASE(mObserver);  NS_IF_RELEASE(mNetSupport);  if (nsnull != mScriptGlobal) {    mScriptGlobal->SetWebShell(nsnull);    NS_RELEASE(mScriptGlobal);  }  NS_IF_RELEASE(mScriptContext);  InitFrameData();  mIsFrame = PR_FALSE;  // XXX Because we hold references to the children and they hold references  // to us we never get destroyed. See Destroy() instead...#if 0  // Release references on our children  ReleaseChildren();#endif  // Free up history memory  PRInt32 i, n = mHistory.Count();  for (i = 0; i < n; i++) {    nsString* s = (nsString*) mHistory.ElementAt(i);    delete s;  }  DestroyPluginHost();}