Bug 1353064 - Add-on always prints at 100% due to missing nsPrintSettingsX::GetScaling() impl r=cosmo0920
authorHaik Aftandilian <haftandilian@mozilla.com>
Wed, 14 Jun 2017 15:06:18 -0700
changeset 418373 5a4f7cc9980579506b199748c9d5cc1479d527c2
parent 418372 7289ba6c2ad114c86b9254d3859040e1251dcc7f
child 418374 b11f89deba4e240ea0cbfafac6d2eb3488e2699a
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscosmo0920
bugs1353064
milestone56.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 1353064 - Add-on always prints at 100% due to missing nsPrintSettingsX::GetScaling() impl r=cosmo0920 MozReview-Commit-ID: AhIFJUfRrPJ
widget/cocoa/nsPrintSettingsX.h
widget/cocoa/nsPrintSettingsX.mm
--- a/widget/cocoa/nsPrintSettingsX.h
+++ b/widget/cocoa/nsPrintSettingsX.h
@@ -61,16 +61,18 @@ public:
   // Re-initialize mAdjustedPaper{Width,Height} with values from mPageFormat.
   // Should be called whenever mPageFormat is initialized or overwritten.
   nsresult InitAdjustedPaperSize();
 
   void SetInchesScale(float aWidthScale, float aHeightScale);
   void GetInchesScale(float *aWidthScale, float *aHeightScale);
 
   NS_IMETHOD SetScaling(double aScaling) override;
+  NS_IMETHOD GetScaling(double *aScaling) override;
+
   NS_IMETHOD SetToFileName(const char16_t * aToFileName) override;
 
   NS_IMETHOD GetOrientation(int32_t *aOrientation) override;
   NS_IMETHOD SetOrientation(int32_t aOrientation) override;
 
   NS_IMETHOD SetUnwriteableMarginTop(double aUnwriteableMarginTop) override;
   NS_IMETHOD SetUnwriteableMarginLeft(double aUnwriteableMarginLeft) override;
   NS_IMETHOD SetUnwriteableMarginBottom(double aUnwriteableMarginBottom) override;
--- a/widget/cocoa/nsPrintSettingsX.mm
+++ b/widget/cocoa/nsPrintSettingsX.mm
@@ -306,16 +306,33 @@ nsPrintSettingsX::SetScaling(double aSca
   SetCocoaPrintInfo(newPrintInfo);
   [newPrintInfo release];
   return NS_OK;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 NS_IMETHODIMP
+nsPrintSettingsX::GetScaling(double *aScaling)
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+
+  NSDictionary* printInfoDict = [mPrintInfo dictionary];
+
+  *aScaling = [[printInfoDict objectForKey: NSPrintScalingFactor] doubleValue];
+
+  // Limit scaling precision to whole number percent values
+  *aScaling = round(*aScaling * 100.0) / 100.0;
+
+  return NS_OK;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+}
+
+NS_IMETHODIMP
 nsPrintSettingsX::SetToFileName(const char16_t *aToFileName)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   NSMutableDictionary* printInfoDict = [mPrintInfo dictionary];
   nsString filename = nsDependentString(aToFileName);
 
   NSURL* jobSavingURL =