mRefCnt = 99;
PresShell::~PresShell(){#ifdef MOZ_REFLOW_PERF  DumpReflows();  if (mReflowCountMgr) {    delete mReflowCountMgr;    mReflowCountMgr = nsnull;  }#endif  // if we allocated any stack memory free it.  FreeDynamicStack();  mRefCnt = 99;/* XXX hack! get around re-entrancy bugs */  mIsDestroying = PR_TRUE;  // Clobber weak leaks in case of re-entrancy during tear down  mHistoryState = nsnull;  // kill subshell map, if any.  It holds only weak references  if (mSubShellMap)  {    delete mSubShellMap;    mSubShellMap = nsnull;  }  // release current event content and any content on event stack  NS_IF_RELEASE(mCurrentEventContent);  PRInt32 i, count = mCurrentEventContentStack.Count();  nsIContent* currentEventContent;  for (i = 0; i < count; i++) {    currentEventContent = (nsIContent*)mCurrentEventContentStack.ElementAt(i);    NS_IF_RELEASE(currentEventContent);  }  if (mViewManager) {    // Disable paints during tear down of the frame tree    mViewManager->DisableRefresh();    mViewManager = nsnull;  }  // Destroy the frame manager. This will destroy the frame hierarchy  NS_IF_RELEASE(mFrameManager);  if (mDocument) {    mDocument->DeleteShell(this);  }  // We hold a reference to the pres context, and it holds a weak link back  // to us. To avoid the pres context having a dangling reference, set its   // pres shell to NULL  if (mPresContext) {    mPresContext->SetShell(nsnull);  }  mRefCnt = 0;  if (mViewEventListener) {    mViewEventListener->SetPresShell((nsIPresShell*)nsnull);    NS_RELEASE(mViewEventListener);  }  // Revoke pending reflow events  if (mPendingReflowEvent) {    mPendingReflowEvent = PR_FALSE;    mEventQueue->RevokeEvents(this);  }}