return Print(printSettings, nsnull);
nsCOMPtr<nsIDeviceContextSpec> devspec; nsCOMPtr<nsIDeviceContext> dx; mPrt->mPrintDC = nsnull;  #ifdef NS_DEBUG mPrt->mDebugFilePtr = mDebugFile; #endif   if (mIsDoingPrintPreview) { aPrintSettings->SetIsPrintPreview(PR_FALSE); }  PRBool printSilently; mPrt->mPrintSettings->GetPrintSilent(&printSilently);     if (!printSilently) { nsCOMPtr<nsIPrintingPromptService> printPromptService(do_GetService(kPrintingPromptService)); if (printPromptService) { nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject; mDocument->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject)); if (!scriptGlobalObject) return nsnull; nsCOMPtr<nsIDOMWindow> domWin = do_QueryInterface(scriptGlobalObject); if (!domWin) return nsnull;        rv = printPromptService->ShowPrintDialog(domWin, this, aPrintSettings); if (rv == NS_ERROR_NOT_IMPLEMENTED) {    rv = NS_OK;  } else if (NS_SUCCEEDED(rv)) {   printSilently = PR_TRUE; } } else { rv = NS_ERROR_GFX_NO_PRINTROMPTSERVICE; } }  if (NS_FAILED(rv)) { if (rv != NS_ERROR_ABORT) { ShowPrintErrorDialog(rv); } delete mPrt; mPrt = nsnull; return rv; }   if ( mIsDoingPrintPreview == PR_TRUE) { aPrintSettings->SetIsPrintPreview(PR_FALSE); }   rv = factory->CreateDeviceContextSpec(mWindow, mPrt->mPrintSettings, *getter_AddRefs(devspec), PR_FALSE);    if (mPrt->mDocWasToBeDestroyed) { mPrt->mPreparingForPrint = PR_FALSE; Destroy(); mIsDoingPrinting = PR_FALSE;   if (rv != NS_ERROR_ABORT) { ShowPrintErrorDialog(NS_ERROR_GFX_PRINTER_DOC_WAS_DESTORYED); } return NS_ERROR_ABORT; }  if (NS_SUCCEEDED(rv)) { rv = mPresContext->GetDeviceContext(getter_AddRefs(dx)); if (NS_SUCCEEDED(rv)) { rv = dx->GetDeviceContextFor(devspec, *getter_AddRefs(mPrt->mPrintDC)); if (NS_SUCCEEDED(rv)) {  mPrt->mPrintDC->GetCanonicalPixelScale(mPrt->mOrigDCScale);  if (!mPrt->mShrinkToFit) { double scaling; mPrt->mPrintSettings->GetScaling(&scaling); mPrt->mPrintDC->SetCanonicalPixelScale(float(scaling)*mPrt->mOrigDCScale); }  if(webContainer) { #ifdef DEBUG_dcone float   a1,a2; PRInt32 i1,i2;  printf("CRITICAL PRINTING INFORMATION\n");   printf("DeviceContext of Presentation Context(%x)\n",dx); dx->GetDevUnitsToTwips(a1); dx->GetTwipsToDevUnits(a2); printf("    DevToTwips = %f TwipToDev = %f\n",a1,a2); dx->GetAppUnitsToDevUnits(a1); dx->GetDevUnitsToAppUnits(a2); printf("    AppUnitsToDev = %f DevUnitsToApp = %f\n",a1,a2); dx->GetCanonicalPixelScale(a1); printf("    GetCanonicalPixelScale = %f\n",a1); dx->GetScrollBarDimensions(a1, a2); printf("    ScrollBar x = %f y = %f\n",a1,a2); dx->GetZoom(a1); printf("    Zoom = %f\n",a1); dx->GetDepth((PRUint32&)i1); printf("    Depth = %d\n",i1); dx->GetDeviceSurfaceDimensions(i1,i2); printf("    DeviceDimension w = %d h = %d\n",i1,i2);    printf("DeviceContext created for print(%x)\n",mPrt->mPrintDC); mPrt->mPrintDC->GetDevUnitsToTwips(a1); mPrt->mPrintDC->GetTwipsToDevUnits(a2); printf("    DevToTwips = %f TwipToDev = %f\n",a1,a2); mPrt->mPrintDC->GetAppUnitsToDevUnits(a1); mPrt->mPrintDC->GetDevUnitsToAppUnits(a2); printf("    AppUnitsToDev = %f DevUnitsToApp = %f\n",a1,a2); mPrt->mPrintDC->GetCanonicalPixelScale(a1); printf("    GetCanonicalPixelScale = %f\n",a1); mPrt->mPrintDC->GetScrollBarDimensions(a1, a2); printf("    ScrollBar x = %f y = %f\n",a1,a2); mPrt->mPrintDC->GetZoom(a1); printf("    Zoom = %f\n",a1); mPrt->mPrintDC->GetDepth((PRUint32&)i1); printf("    Depth = %d\n",i1); mPrt->mPrintDC->GetDeviceSurfaceDimensions(i1,i2); printf("    DeviceDimension w = %d h = %d\n",i1,i2);  #endif           PRInt16 printFrameTypeUsage = nsIPrintSettings::kUseSettingWhenPossible; mPrt->mPrintSettings->GetPrintFrameTypeUsage(&printFrameTypeUsage);   if (printFrameTypeUsage == nsIPrintSettings::kUseSettingWhenPossible) {  PRInt16 printFrameType = nsIPrintSettings::kEachFrameSep; mPrt->mPrintSettings->GetPrintFrameType(&printFrameType);    if (printFrameType == nsIPrintSettings::kNoFrames) { mPrt->mPrintFrameType = nsIPrintSettings::kEachFrameSep; mPrt->mPrintSettings->SetPrintFrameType(mPrt->mPrintFrameType); } else {   PRInt16 howToEnableFrameUI; mPrt->mPrintSettings->GetHowToEnableFrameUI(&howToEnableFrameUI); if (howToEnableFrameUI != nsIPrintSettings::kFrameEnableNone) { switch (howToEnableFrameUI) { case nsIPrintSettings::kFrameEnableAll: mPrt->mPrintFrameType = printFrameType; break;  case nsIPrintSettings::kFrameEnableAsIsAndEach: if (printFrameType != nsIPrintSettings::kSelectedFrame) { mPrt->mPrintFrameType = printFrameType; } else { mPrt->mPrintFrameType = nsIPrintSettings::kEachFrameSep; } break; } mPrt->mPrintSettings->SetPrintFrameType(mPrt->mPrintFrameType); } } }   PRUnichar* fileName = nsnull;  PRBool isPrintToFile = PR_FALSE; mPrt->mPrintSettings->GetPrintToFile(&isPrintToFile); if (isPrintToFile) {   mPrt->mPrintSettings->GetToFileName(&fileName); }  PRUnichar * docTitleStr; PRUnichar * docURLStr;  GetDisplayTitleAndURL(mPrt->mPrintObject, mPrt->mPrintSettings, mPrt->mBrandName, &docTitleStr, &docURLStr, eDocTitleDefURLDoc);  rv = mPrt->mPrintDC->PrepareDocument(docTitleStr, fileName);  if (docTitleStr) nsMemory::Free(docTitleStr); if (docURLStr) nsMemory::Free(docURLStr); NS_ENSURE_SUCCESS(rv, rv);  DoPrintProgress(PR_TRUE);   if (mPrt != nsnull) { mPrt->OnStartPrinting(); }  rv = DocumentReadyForPrinting(); PRINT_DEBUG_MSG1("PRINT JOB ENDING, OBSERVER WAS NOT CALLED\n"); } } } } else { mPrt->mPrintSettings->SetIsCancelled(PR_TRUE); }   if (mIsDoingPrintPreview) { aPrintSettings->SetIsPrintPreview(PR_TRUE); } }   if (NS_FAILED(rv)) {  if (mPagePrintTimer) { mPagePrintTimer->Stop(); NS_RELEASE(mPagePrintTimer); }  if (mPrt) { delete mPrt; mPrt = nsnull; } mIsDoingPrinting = PR_FALSE;   if (rv != NS_ERROR_ABORT) { ShowPrintErrorDialog(rv); } }  return rv;
DocumentViewerImpl::Print(PRBool            aSilent,                          FILE *            aDebugFile,                          nsIPrintSettings* aPrintSettings){  nsCOMPtr<nsIPrintSettings> printSettings;#ifdef NS_DEBUG  nsresult rv = NS_ERROR_FAILURE;  mDebugFile = aDebugFile;  // if they don't pass in a PrintSettings, then make one  // it will have all the default values  printSettings = aPrintSettings;  nsCOMPtr<nsIPrintOptions> printOptions = do_GetService(kPrintOptionsCID, &rv);  if (NS_SUCCEEDED(rv)) {    // if they don't pass in a PrintSettings, then make one    if (printSettings == nsnull) {      printOptions->CreatePrintSettings(getter_AddRefs(printSettings));    }    NS_ASSERTION(printSettings, "You can't PrintPreview without a PrintSettings!");  }  if (printSettings) printSettings->SetPrintSilent(aSilent);#endif  return Print(printSettings, nsnull);}