Bug 1636725 p2. Properly save the settings chosen by the user in the Page Setup dialog on macOS. r=bobowen

Depends on D74547

Differential Revision: https://phabricator.services.mozilla.com/D74548
This commit is contained in:
Jonathan Watt 2020-05-11 14:23:12 +00:00
Родитель 6c2bfc599b
Коммит 28edea04b6
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -188,8 +188,10 @@ nsPrintDialogServiceX::ShowPageSetup(nsPIDOMWindowOuter* aParent, nsIPrintSettin
nsCOMPtr<nsIPrintSettingsService> printSettingsService =
do_GetService("@mozilla.org/gfx/printsettings-service;1");
if (printSettingsService && Preferences::GetBool("print.save_print_settings", false)) {
printSettingsService->SavePrintSettingsToPrefs(aNSSettings, true,
nsIPrintSettings::kInitSaveNativeData);
uint32_t flags = nsIPrintSettings::kInitSaveNativeData |
nsIPrintSettings::kInitSavePaperSize |
nsIPrintSettings::kInitSaveOrientation | nsIPrintSettings::kInitSaveScaling;
printSettingsService->SavePrintSettingsToPrefs(aNSSettings, true, flags);
}
return NS_OK;
}

Просмотреть файл

@ -24,6 +24,13 @@ NS_IMPL_ISUPPORTS_INHERITED(nsPrintSettingsX, nsPrintSettings, nsPrintSettingsX)
nsPrintSettingsX::nsPrintSettingsX() : mAdjustedPaperWidth{0.0}, mAdjustedPaperHeight{0.0} {
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
// Note that the app shared `sharedPrintInfo` object is special! The system
// print dialog and print settings dialog update it with the values chosen
// by the user. Using that object here to initialize new nsPrintSettingsX
// objects could mask bugs in our code where we fail to save and/or restore
// print settings ourselves (e.g., bug 1636725). On other platforms we only
// initialize new nsPrintSettings objects from the settings that we save to
// prefs. Perhaps we should stop using sharedPrintInfo here for consistency?
mPrintInfo = [[NSPrintInfo sharedPrintInfo] copy];
mWidthScale = COCOA_PAPER_UNITS_PER_INCH;
mHeightScale = COCOA_PAPER_UNITS_PER_INCH;