Bug 675709 - Set needed paper size information when printing info PDF on macOS. r=haik
☠☠ backed out by 31590ab43f61 ☠ ☠
authorHiroshi Hatake <cosmo0920.oucc@gmail.com>
Sat, 21 Jan 2017 17:42:37 +0900
changeset 340883 d88c174c2d20fe3f20b2c7bc5ffe73a154c5079f
parent 340882 2114a592360dffbeb0c4588f20c809d7438c49bb
child 340884 9d763f7c2d4ca95bb9f59d73091e075528b8373e
push id31318
push usercbook@mozilla.com
push dateMon, 06 Feb 2017 11:56:59 +0000
treeherdermozilla-central@1cc159c7a044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershaik
bugs675709
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 675709 - Set needed paper size information when printing info PDF on macOS. r=haik
widget/cocoa/nsDeviceContextSpecX.mm
--- a/widget/cocoa/nsDeviceContextSpecX.mm
+++ b/widget/cocoa/nsDeviceContextSpecX.mm
@@ -59,16 +59,29 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init
                                          bool aIsPrintPreview)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   RefPtr<nsPrintSettingsX> settings(do_QueryObject(aPS));
   if (!settings)
     return NS_ERROR_NO_INTERFACE;
 
+  bool toFile;
+  settings->GetPrintToFile(&toFile);
+
+  bool toPrinter = !toFile && !aIsPrintPreview;
+  if (!toPrinter) {
+    double width, height;
+    settings->GetEffectivePageSize(&width, &height);
+    width /= TWIPS_PER_POINT_FLOAT;
+    height /= TWIPS_PER_POINT_FLOAT;
+
+    settings->SetCocoaPaperSize(width, height);
+  }
+
   mPrintSession = settings->GetPMPrintSession();
   ::PMRetain(mPrintSession);
   mPageFormat = settings->GetPMPageFormat();
   mPrintSettings = settings->GetPMPrintSettings();
 
 #ifdef MOZ_ENABLE_SKIA_PDF
   const nsAdoptingString& printViaPdf =
     mozilla::Preferences::GetString("print.print_via_pdf_encoder");