diff options
Diffstat (limited to 'layout/base/nsDocumentViewer.cpp')
-rw-r--r-- | layout/base/nsDocumentViewer.cpp | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index d1cf9bf237..8ae0e001b8 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -449,6 +449,7 @@ class nsDocumentViewer final : public nsIDocumentViewer, #ifdef NS_PRINTING unsigned mClosingWhilePrinting : 1; + unsigned mCloseWindowAfterPrint : 1; # if NS_PRINT_PREVIEW RefPtr<nsPrintJob> mPrintJob; @@ -520,6 +521,7 @@ nsDocumentViewer::nsDocumentViewer() mInPermitUnloadPrompt(false), #ifdef NS_PRINTING mClosingWhilePrinting(false), + mCloseWindowAfterPrint(false), #endif // NS_PRINTING mReloadEncodingSource(kCharsetUninitialized), mReloadEncoding(nullptr), @@ -3140,6 +3142,20 @@ nsDocumentViewer::GetDoingPrintPreview(bool* aDoingPrintPreview) { } NS_IMETHODIMP +nsDocumentViewer::GetCloseWindowAfterPrint(bool* aCloseWindowAfterPrint) { + NS_ENSURE_ARG_POINTER(aCloseWindowAfterPrint); + + *aCloseWindowAfterPrint = mCloseWindowAfterPrint; + return NS_OK; +} + +NS_IMETHODIMP +nsDocumentViewer::SetCloseWindowAfterPrint(bool aCloseWindowAfterPrint) { + mCloseWindowAfterPrint = aCloseWindowAfterPrint; + return NS_OK; +} + +NS_IMETHODIMP nsDocumentViewer::ExitPrintPreview() { NS_ENSURE_TRUE(mPrintJob, NS_ERROR_FAILURE); @@ -3301,15 +3317,23 @@ void nsDocumentViewer::OnDonePrinting() { printJob->Destroy(); } - // We are done printing, now clean up. - // - // For non-print-preview jobs, we are actually responsible for cleaning up - // our whole <browser> or window (see the OPEN_PRINT_BROWSER code), so gotta - // run window.close(), which will take care of this. - // - // For print preview jobs the front-end code is responsible for cleaning the - // UI. - if (!printJob->CreatedForPrintPreview()) { +// We are done printing, now clean up. +// +// If the original document to print was not a static clone, we opened a new +// window and are responsible for cleaning up the whole <browser> or window +// (see the OPEN_PRINT_BROWSER code, specifically +// handleStaticCloneCreatedForPrint()), so gotta run window.close(), which +// will take care of this. +// +// Otherwise the front-end code is responsible for cleaning the UI. +# ifdef ANDROID + // Android doesn't support Content Analysis and prints in a different way, + // so use different logic to clean up. + bool closeWindowAfterPrint = !printJob->CreatedForPrintPreview(); +# else + bool closeWindowAfterPrint = GetCloseWindowAfterPrint(); +# endif + if (closeWindowAfterPrint) { if (mContainer) { if (nsCOMPtr<nsPIDOMWindowOuter> win = mContainer->GetWindow()) { win->Close(); |