Bug 1319116 - Part 2 - "Cancel" reverts header and footer settings to defaults r=jwatt

On Mac, don't attempt to save print settings after the user cancels out of the print dialog.

Differential Revision: https://phabricator.services.mozilla.com/D23889

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Haik Aftandilian 2019-04-01 14:42:24 +00:00
Родитель 29bb07756f
Коммит ec23270654
5 изменённых файлов: 23 добавлений и 2 удалений

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

@ -323,6 +323,7 @@ class PrintingChild extends ActorChild {
print(contentWindow, simplifiedMode, defaultPrinterName) {
let printSettings = this.getPrintSettings(defaultPrinterName);
let printCancelled = false;
// If we happen to be on simplified mode, we need to set docURL in order
// to generate header/footer content correctly, since simplified tab has
@ -354,7 +355,9 @@ class PrintingChild extends ActorChild {
} catch (e) {
// Pressing cancel is expressed as an NS_ERROR_ABORT return value,
// causing an exception to be thrown which we catch here.
if (e.result != Cr.NS_ERROR_ABORT) {
if (e.result == Cr.NS_ERROR_ABORT) {
printCancelled = true;
} else {
Cu.reportError(`In Printing:Print:Done handler, got unexpected rv
${e.result}.`);
this.mm.sendAsyncMessage("Printing:Error", {
@ -364,7 +367,8 @@ class PrintingChild extends ActorChild {
}
}
if (this.shouldSavePrintSettings) {
if ((!printCancelled || printSettings.saveOnCancel) &&
this.shouldSavePrintSettings) {
let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"]
.getService(Ci.nsIPrintSettingsService);

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

@ -28,6 +28,15 @@ nsPrintSettingsX::nsPrintSettingsX() : mAdjustedPaperWidth{0.0}, mAdjustedPaperH
mWidthScale = COCOA_PAPER_UNITS_PER_INCH;
mHeightScale = COCOA_PAPER_UNITS_PER_INCH;
/*
* Don't save print settings after the user cancels out of the
* print dialog. For saving print settings after a cancellation
* to work properly, in addition to changing |mSaveOnCancel|,
* the print dialog implementation must be updated to save changed
* settings and serialize them back to the child process.
*/
mSaveOnCancel = false;
NS_OBJC_END_TRY_ABORT_BLOCK;
}

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

@ -215,6 +215,7 @@ interface nsIPrintSettings : nsISupports
attribute short howToEnableFrameUI; /* indicates how to enable the frameset UI */
attribute boolean isCancelled; /* indicates whether the print job has been cancelled */
readonly attribute boolean saveOnCancel; /* indicates whether the print settings should be saved after a cancel */
attribute short printFrameTypeUsage; /* indicates whether to use the interal value or not */
attribute short printFrameType;
attribute boolean printSilent; /* print without putting up the dialog */

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

@ -24,6 +24,7 @@ nsPrintSettings::nsPrintSettings()
mPrintFrameType(kFramesAsIs),
mHowToEnableFrameUI(kFrameEnableNone),
mIsCancelled(false),
mSaveOnCancel(true),
mPrintSilent(false),
mPrintPreview(false),
mShrinkToFit(true),
@ -620,6 +621,11 @@ NS_IMETHODIMP nsPrintSettings::SetIsCancelled(bool aIsCancelled) {
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetSaveOnCancel(bool *aSaveOnCancel) {
*aSaveOnCancel = mSaveOnCancel;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetPaperWidth(double *aPaperWidth) {
NS_ENSURE_ARG_POINTER(aPaperWidth);
*aPaperWidth = mPaperWidth;

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

@ -59,6 +59,7 @@ class nsPrintSettings : public nsIPrintSettings {
int16_t mPrintFrameType;
int16_t mHowToEnableFrameUI;
bool mIsCancelled;
bool mSaveOnCancel;
bool mPrintSilent;
bool mPrintPreview;
bool mShrinkToFit;