DocumentViewerImpl::SetupToPrintContent(nsIWebShell *      aParent, nsIDeviceContext * aDContext, nsIDOMWindow     * aDOMWin)
DocumentViewerImpl::SetupToPrintContent(nsIWebShell*          aParent, nsIDeviceContext*     aDContext, nsIDOMWindowInternal* aCurrentFocusedDOMWin)
DocumentViewerImpl::SetupToPrintContent(nsIWebShell *      aParent,                                        nsIDeviceContext * aDContext,                                        nsIDOMWindow     * aDOMWin){  NS_ENSURE_ARG_POINTER(aParent);  NS_ENSURE_ARG_POINTER(aDContext);  nsCOMPtr<nsIDocShellTreeNode>  parentAsNode(do_QueryInterface(aParent));  nsCOMPtr<nsIDOMWindowInternal> domWinIntl(do_QueryInterface(aDOMWin));  mIsIFrameSelection = IsThereAnIFrameSelected(aParent, domWinIntl, mDoesContainFrameSet);  PRInt16 printFrameType = nsIPrintOptions::kSelectedFrame; // XXX later this default to kFramesAsIs  nsresult rv;  NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);  if (NS_SUCCEEDED(rv) && printService) {    printService->GetPrintFrameType(&printFrameType);  }  if (printFrameType == nsIPrintOptions::kFramesAsIs) {    // print frameset "as is " here and return    return NS_OK;  }  // Create a list for storing the WebShells that need to be printed  if (mPrintDocList == nsnull) {    mPrintDocList = new nsVoidArray();    if (mPrintDocList == nsnull) {      return NS_ERROR_FAILURE;    }  } else {    mPrintDocList->Clear();  }  // If there are no Sub docs than add "this" webshell to the list  MakeDocPrintList(parentAsNode, mPrintDocList);  if (mPrintDocList->Count() == 0) {    mPrintDocList->AppendElement(aParent);  }  mPrintDocDC = aDContext;  mPrintDocDW = aDOMWin;  mTimerAlreadyStarted = PR_FALSE;  // This will print the webshell document  // when it completes asynchronously in the DonePrintingPages method  // it will check to see if there are more webshells to be printed and   // then PrintDocContent will be called again.  nsCOMPtr<nsIWebShell> webContainer(do_QueryInterface(mContainer));  PRUnichar * docTitleStr = GetWebShellTitle(webContainer);  // BeginDocument may pass back a FAILURE code  // i.e. On Windows, if you are printing to a file and hit "Cancel"   //      to the "File Name" dialog  rv = mPrintDC->BeginDocument(docTitleStr);  if (docTitleStr != nsnull) {    nsMemory::Free(docTitleStr);  }  if (NS_FAILED(rv)) {    return rv;  }  return PrintDocContent();}