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
--- 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; }