if (mPrtPreview) { TurnScriptingOn(PR_TRUE);
if (GetIsPrintPreview() && mPrintEngine) { mPrintEngine->TurnScriptingOn(PR_TRUE);
DocumentViewerImpl::Close(){  // All callers are supposed to call close to break circular  // references.  If we do this stuff in the destructor, the  // destructor might never be called (especially if we're being  // used from JS.  // Close is also needed to disable scripts during paint suppression,  // since we transfer the existing global object to the new document  // that is loaded.  In the future, the global object may become a proxy  // for an object that can be switched in and out so that we don't need  // to disable scripts during paint suppression.  if (mDocument) {#ifdef NS_PRINT_PREVIEW    // Turn scripting back on    // after PrintPreview had turned it off    if (mPrtPreview) {      TurnScriptingOn(PR_TRUE);    }#endif    // Before we clear the script global object, clear the undisplayed    // content map, since XBL content can be destroyed by the    // |SetDocument(null, ...)| triggered by calling    // |SetScriptGlobalObject(null)|.    if (mPresShell) {      nsCOMPtr<nsIFrameManager> frameManager;      mPresShell->GetFrameManager(getter_AddRefs(frameManager));      if (frameManager)        frameManager->ClearUndisplayedContentMap();    }    // Break global object circular reference on the document created    // in the DocViewer Init    nsCOMPtr<nsIScriptGlobalObject> globalObject;    mDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));    if (globalObject) {      globalObject->SetNewDocument(nsnull, PR_TRUE, PR_TRUE);    }    // out of band cleanup of webshell    mDocument->SetScriptGlobalObject(nsnull);    if (mFocusListener) {      // get the DOM event receiver      nsCOMPtr<nsIDOMEventReceiver> erP(do_QueryInterface(mDocument));      NS_WARN_IF_FALSE(erP, "No event receiver in document!");      if (erP) {        erP->RemoveEventListenerByIID(mFocusListener,                                      NS_GET_IID(nsIDOMFocusListener));      }    }  }  mDocument = nsnull;  return NS_OK;}