diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c746c00e4f3c..bd4212741ccc 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -913,6 +913,14 @@ pref("browser.fixup.alternate.prefix", "www."); pref("browser.fixup.alternate.suffix", ".com"); pref("browser.fixup.fallback-to-https", true); +// NOTE: On most platforms we save print settins to prefs with the name of the +// printer in the pref name (Android being the notable exception, where prefs +// are saved "globally" without a printer name in the pref name). For those +// platforms, the prefs below simply act as default values for when we +// encounter a printer for the first time, but only a subset of prefs will be +// used in this case. See nsPrintSettingsService::InitPrintSettingsFromPrefs +// for the restrictions on which prefs can act as defaults. + // Print/Preview Shrink-To-Fit won't shrink below 20% for text-ish documents. pref("print.shrink-to-fit.scale-limit-percent", 20); diff --git a/widget/cocoa/nsPrintSettingsServiceX.mm b/widget/cocoa/nsPrintSettingsServiceX.mm index 5c38a6fd8b14..ff2fc92008b9 100644 --- a/widget/cocoa/nsPrintSettingsServiceX.mm +++ b/widget/cocoa/nsPrintSettingsServiceX.mm @@ -173,7 +173,17 @@ nsresult nsPrintSettingsServiceX::_CreatePrintSettings(nsIPrintSettings** _retva return rv; } - InitPrintSettingsFromPrefs(*_retval, false, nsIPrintSettings::kInitSaveAll); + auto globalPrintSettings = + nsIPrintSettings::kInitSaveShrinkToFit | nsIPrintSettings::kInitSaveHeaderLeft | + nsIPrintSettings::kInitSaveHeaderCenter | nsIPrintSettings::kInitSaveHeaderRight | + nsIPrintSettings::kInitSaveFooterLeft | nsIPrintSettings::kInitSaveFooterCenter | + nsIPrintSettings::kInitSaveFooterRight | nsIPrintSettings::kInitSaveEdges | + nsIPrintSettings::kInitSaveReversed | nsIPrintSettings::kInitSaveInColor; + + // XXX Why is Mac special? Why are we copying global print settings here? + // nsPrintSettingsService::InitPrintSettingsFromPrefs already gets the few + // global defaults that we want, doesn't it? + InitPrintSettingsFromPrefs(*_retval, false, globalPrintSettings); return rv; } diff --git a/widget/nsPrintSettingsService.cpp b/widget/nsPrintSettingsService.cpp index b70417744bf7..d21523bdee4d 100644 --- a/widget/nsPrintSettingsService.cpp +++ b/widget/nsPrintSettingsService.cpp @@ -938,10 +938,24 @@ nsPrintSettingsService::InitPrintSettingsFromPrefs(nsIPrintSettings* aPS, if (isInitialized) return NS_OK; + auto globalPrintSettings = aFlags; +#ifndef MOZ_WIDGET_ANDROID + globalPrintSettings &= nsIPrintSettings::kInitSaveShrinkToFit | + nsIPrintSettings::kInitSaveHeaderLeft | + nsIPrintSettings::kInitSaveHeaderCenter | + nsIPrintSettings::kInitSaveHeaderRight | + nsIPrintSettings::kInitSaveFooterLeft | + nsIPrintSettings::kInitSaveFooterCenter | + nsIPrintSettings::kInitSaveFooterRight | + nsIPrintSettings::kInitSaveEdges | + nsIPrintSettings::kInitSaveReversed | + nsIPrintSettings::kInitSaveInColor; +#endif + nsAutoString prtName; // read any non printer specific prefs // with empty printer name - nsresult rv = ReadPrefs(aPS, prtName, aFlags); + nsresult rv = ReadPrefs(aPS, prtName, globalPrintSettings); NS_ENSURE_SUCCESS(rv, rv); // Get the Printer Name from the PrintSettings to use as a prefix for Pref