Bug 1661823 - Fix Default Print Settings Unwriteable Margins Units. r=AlaskanEmily, a=RyanVM
authorErik Nordin <nordzilla@mozilla.com>
Fri, 28 Aug 2020 21:53:34 +0000
changeset 610674 0ec3a7607e34e9ddc74732367e1ac71fb66799f0
parent 610673 b4cf43a3ba5bb54163cded85e316d8ad6991fd66
child 610675 80a0372d4797b1c35e960c7dc7353a1eda06859d
push id13706
push userryanvm@gmail.com
push dateMon, 31 Aug 2020 21:29:33 +0000
treeherdermozilla-beta@80a0372d4797 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersAlaskanEmily, RyanVM
bugs1661823
milestone81.0
Bug 1661823 - Fix Default Print Settings Unwriteable Margins Units. r=AlaskanEmily, a=RyanVM Print settings stores margin units in TWIPS, but the API expects inches. This was causing an extra conversion from inches to TWIPS on values that were already in TWIPS. Differential Revision: https://phabricator.services.mozilla.com/D88674
widget/nsPrintSettingsImpl.cpp
--- a/widget/nsPrintSettingsImpl.cpp
+++ b/widget/nsPrintSettingsImpl.cpp
@@ -69,20 +69,21 @@ void nsPrintSettings::InitWithInitialize
   SetResolution(aSettings.mResolution);
   SetPaperName(aSettings.mPaperInfo.mName);
   SetPaperWidth(aSettings.mPaperInfo.mSize.Width() * kInchesPerPoint);
   SetPaperHeight(aSettings.mPaperInfo.mSize.Height() * kInchesPerPoint);
   SetPaperSizeUnit(nsIPrintSettings::kPaperSizeInches);
 
   if (aSettings.mPaperInfo.mUnwriteableMargin) {
     const auto& margin = aSettings.mPaperInfo.mUnwriteableMargin.value();
-    SetUnwriteableMarginTop(NS_POINTS_TO_TWIPS(margin.top));
-    SetUnwriteableMarginRight(NS_POINTS_TO_TWIPS(margin.right));
-    SetUnwriteableMarginBottom(NS_POINTS_TO_TWIPS(margin.bottom));
-    SetUnwriteableMarginLeft(NS_POINTS_TO_TWIPS(margin.left));
+    // Margins are stored internally in TWIPS, but the setters expect inches.
+    SetUnwriteableMarginTop(margin.top * kInchesPerPoint);
+    SetUnwriteableMarginRight(margin.right * kInchesPerPoint);
+    SetUnwriteableMarginBottom(margin.bottom * kInchesPerPoint);
+    SetUnwriteableMarginLeft(margin.left * kInchesPerPoint);
   }
 
   // Set this last because other setters may overwrite its value.
   SetIsInitializedFromPrinter(true);
 }
 
 nsPrintSettings::nsPrintSettings(const nsPrintSettings& aPS) { *this = aPS; }