nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryReferent(mContainer); if (treeItem) {   nsCOMPtr<nsIDocShellTreeItem> root; treeItem->GetSameTypeRootTreeItem(getter_AddRefs(root)); nsCOMPtr<nsIWebNavigation> webNav = do_QueryInterface(root); nsCOMPtr<nsISHistory> history; webNav->GetSessionHistory(getter_AddRefs(history)); nsCOMPtr<nsISHistoryInternal> historyInt = do_QueryInterface(history); if (historyInt) { PRInt32 prevIndex,loadedIndex; nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(treeItem); docShell->GetPreviousTransIndex(&prevIndex); docShell->GetLoadedTransIndex(&loadedIndex); #ifdef DEBUG_PAGE_CACHE printf("About to evict content viewers: prev=%d, loaded=%d\n", prevIndex, loadedIndex); #endif historyInt->EvictContentViewers(prevIndex, loadedIndex); } }
DocumentViewerImpl::Show(void){  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);  // We don't need the previous viewer anymore since we're not  // displaying it.  if (mPreviousViewer) {    // This little dance *may* only be to keep    // PresShell::EndObservingDocument happy, but I'm not sure.    nsCOMPtr<nsIContentViewer> prevViewer(mPreviousViewer);    mPreviousViewer = nsnull;    prevViewer->Destroy();  }  if (mWindow) {    mWindow->Show(PR_TRUE);  }  if (mDocument && !mPresShell && !mWindow) {    nsresult rv;    nsCOMPtr<nsIBaseWindow> base_win(do_QueryReferent(mContainer));    NS_ENSURE_TRUE(base_win, NS_ERROR_UNEXPECTED);    base_win->GetParentWidget(&mParentWidget);    NS_ENSURE_TRUE(mParentWidget, NS_ERROR_UNEXPECTED);    mDeviceContext = dont_AddRef(mParentWidget->GetDeviceContext());#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)    // Clear PrintPreview Alternate Device    if (mDeviceContext) {      mDeviceContext->SetAltDevice(nsnull);    }#endif    // Create presentation context    if (GetIsCreatingPrintPreview()) {      NS_ERROR("Whoa, we should not get here!");      return NS_ERROR_UNEXPECTED;    }    NS_ASSERTION(!mPresContext, "Shouldn't have a prescontext if we have no shell!");    mPresContext = new nsPresContext(nsPresContext::eContext_Galley);    NS_ENSURE_TRUE(mPresContext, NS_ERROR_OUT_OF_MEMORY);    rv = mPresContext->Init(mDeviceContext);    if (NS_FAILED(rv)) {      mPresContext = nsnull;      return rv;    }    nsRect tbounds;    mParentWidget->GetBounds(tbounds);    rv = MakeWindow(mParentWidget, tbounds);    if (NS_FAILED(rv))      return rv;    if (mPresContext && base_win) {      nsCOMPtr<nsILinkHandler> linkHandler(do_GetInterface(base_win));      if (linkHandler) {        mPresContext->SetLinkHandler(linkHandler);      }      mPresContext->SetContainer(base_win);    }    if (mPresContext) {      Hide();      rv = InitPresentationStuff(PR_TRUE);    }    // If we get here the document load has already started and the    // window is shown because some JS on the page caused it to be    // shown...    mPresShell->UnsuppressPainting();  }  return NS_OK;}