if (!mPresShell || mIsDoingPrintPreview) {
if (!mPresShell || GetIsPrintPreview()) {
DocumentViewerImpl::Hide(void){  PRBool is_in_print_mode = PR_FALSE;  GetDoingPrint(&is_in_print_mode);  if (is_in_print_mode) {    // If we, or one of our parents, is in print mode it means we're    // right now returning from print and the layout frame that was    // created for this document is being destroyed. In such a case we    // ignore the Hide() call.    return NS_OK;  }  GetDoingPrintPreview(&is_in_print_mode);  if (is_in_print_mode) {    // If we, or one of our parents, is in print preview mode it means    // we're right now returning from print preview and the layout    // frame that was created for this document is being destroyed. In    // such a case we ignore the Hide() call.    return NS_OK;  }  NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);  NS_PRECONDITION(mWindow, "null window");  if (mWindow) {    mWindow->Show(PR_FALSE);  }  if (!mPresShell || mIsDoingPrintPreview) {    return NS_OK;  }  // Avoid leaking the old viewer.  if (mPreviousViewer) {    mPreviousViewer->Destroy();    mPreviousViewer = nsnull;  }  if (mIsSticky) {    // This window is sticky, that means that it might be shown again    // and we don't want the presshell n' all that to be thrown away    // just because the window is hidden.    return NS_OK;  }  if (mDeviceContext) {    mDeviceContext->FlushFontCache();  }  // Break circular reference (or something)  mPresShell->EndObservingDocument();  nsCOMPtr<nsISelection> selection;  GetDocumentSelection(getter_AddRefs(selection));  nsCOMPtr<nsISelectionPrivate> selPrivate(do_QueryInterface(selection));  if (selPrivate && mSelectionListener) {    selPrivate->RemoveSelectionListener(mSelectionListener);  }  nsCOMPtr<nsIXULDocument> xul_doc(do_QueryInterface(mDocument));  if (xul_doc) {    xul_doc->OnHide();  }  mPresShell->Destroy();  mPresShell     = nsnull;  mPresContext   = nsnull;  mViewManager   = nsnull;  mWindow        = nsnull;  mDeviceContext = nsnull;  mParentWidget  = nsnull;  nsCOMPtr<nsIBaseWindow> base_win(do_QueryInterface(mContainer));  if (base_win) {    base_win->SetParentWidget(nsnull);  }  return NS_OK;}