From ac90ddff59c7b67c658666243053f3c7e6c1c797 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Thu, 16 Dec 2021 15:12:33 +0000 Subject: [PATCH] Bug 1745452 - Remove the print progress dialog code. r=mstriemer,bobowen,webdriver-reviewers Differential Revision: https://phabricator.services.mozilla.com/D133500 --- .../static/browser_all_files_referenced.js | 2 +- .../components/extensions/parent/ext-tabs.js | 1 - ipc/ipdl/ipdl/direct_call.py | 4 +- layout/base/nsDocumentViewer.cpp | 1 - .../printpreview_bug396024_helper.xhtml | 1 - .../printpreview_bug482976_helper.xhtml | 1 - .../tests/chrome/printpreview_helper.xhtml | 1 - layout/printing/ipc/RemotePrintJobParent.cpp | 1 + layout/printing/moz.build | 7 - layout/printing/nsIPrintProgress.idl | 43 --- layout/printing/nsIPrintProgressParams.idl | 14 - layout/printing/nsPrintData.cpp | 1 - layout/printing/nsPrintData.h | 2 - layout/printing/nsPrintJob.cpp | 179 +----------- layout/printing/nsPrintJob.h | 16 +- layout/tools/reftest/reftest.jsm | 1 - remote/cdp/domains/parent/Page.jsm | 1 - remote/marionette/print.js | 1 - toolkit/actors/PrintingChild.jsm | 3 - toolkit/actors/PrintingParent.jsm | 26 +- .../browser/nsIPrintingPromptService.idl | 26 -- toolkit/components/printing/content/print.js | 5 - .../printing/content/printPreviewProgress.js | 152 ---------- .../content/printPreviewProgress.xhtml | 34 --- .../printing/content/printProgress.js | 230 --------------- .../printing/content/printProgress.xhtml | 47 ---- .../components/printing/content/printUtils.js | 92 +----- toolkit/components/printing/jar.mn | 6 - .../printingui/ipc/PPrintProgressDialog.ipdl | 36 --- .../components/printingui/ipc/PPrinting.ipdl | 8 - .../printingui/ipc/PPrintingTypes.ipdlh | 1 - .../ipc/PrintProgressDialogChild.cpp | 128 --------- .../printingui/ipc/PrintProgressDialogChild.h | 44 --- .../ipc/PrintProgressDialogParent.cpp | 111 -------- .../ipc/PrintProgressDialogParent.h | 57 ---- .../printingui/ipc/PrintingParent.cpp | 74 ----- .../printingui/ipc/PrintingParent.h | 9 - toolkit/components/printingui/ipc/moz.build | 3 - .../printingui/ipc/nsPrintingProxy.cpp | 71 ----- .../printingui/ipc/nsPrintingProxy.h | 5 - toolkit/components/printingui/moz.build | 5 - .../components/printingui/nsPrintProgress.cpp | 265 ------------------ .../components/printingui/nsPrintProgress.h | 44 --- .../printingui/nsPrintProgressParams.cpp | 37 --- .../printingui/nsPrintProgressParams.h | 27 -- .../printingui/nsPrintingPromptService.cpp | 149 +--------- .../printingui/nsPrintingPromptService.h | 10 +- widget/nsIPrintSettings.idl | 1 - widget/nsPrintSettingsImpl.cpp | 12 - widget/nsPrintSettingsImpl.h | 1 - widget/nsPrintSettingsService.cpp | 2 - 51 files changed, 17 insertions(+), 1981 deletions(-) delete mode 100644 layout/printing/nsIPrintProgress.idl delete mode 100644 layout/printing/nsIPrintProgressParams.idl delete mode 100644 toolkit/components/printing/content/printPreviewProgress.js delete mode 100644 toolkit/components/printing/content/printPreviewProgress.xhtml delete mode 100644 toolkit/components/printing/content/printProgress.js delete mode 100644 toolkit/components/printing/content/printProgress.xhtml delete mode 100644 toolkit/components/printingui/ipc/PPrintProgressDialog.ipdl delete mode 100644 toolkit/components/printingui/ipc/PrintProgressDialogChild.cpp delete mode 100644 toolkit/components/printingui/ipc/PrintProgressDialogChild.h delete mode 100644 toolkit/components/printingui/ipc/PrintProgressDialogParent.cpp delete mode 100644 toolkit/components/printingui/ipc/PrintProgressDialogParent.h delete mode 100644 toolkit/components/printingui/nsPrintProgress.cpp delete mode 100644 toolkit/components/printingui/nsPrintProgress.h delete mode 100644 toolkit/components/printingui/nsPrintProgressParams.cpp delete mode 100644 toolkit/components/printingui/nsPrintProgressParams.h diff --git a/browser/base/content/test/static/browser_all_files_referenced.js b/browser/base/content/test/static/browser_all_files_referenced.js index 23387b3b9896..5fe231df020a 100644 --- a/browser/base/content/test/static/browser_all_files_referenced.js +++ b/browser/base/content/test/static/browser_all_files_referenced.js @@ -107,7 +107,7 @@ var whitelist = [ }, { file: "resource://gre/localization/en-US/toolkit/printing/printDialogs.ftl", - platforms: ["macosx"], + platforms: ["linux", "macosx"], }, // toolkit/content/aboutRights-unbranded.xhtml doesn't use aboutRights.css diff --git a/browser/components/extensions/parent/ext-tabs.js b/browser/components/extensions/parent/ext-tabs.js index e43de3cee445..559ad32857aa 100644 --- a/browser/components/extensions/parent/ext-tabs.js +++ b/browser/components/extensions/parent/ext-tabs.js @@ -1356,7 +1356,6 @@ this.tabs = class extends ExtensionAPI { printSettings.toFileName = picker.file.path; printSettings.printSilent = true; - printSettings.showPrintProgress = false; printSettings.outputFormat = Ci.nsIPrintSettings.kOutputFormatPDF; diff --git a/ipc/ipdl/ipdl/direct_call.py b/ipc/ipdl/ipdl/direct_call.py index 413e91275b0e..732d05df9712 100644 --- a/ipc/ipdl/ipdl/direct_call.py +++ b/ipc/ipdl/ipdl/direct_call.py @@ -678,12 +678,10 @@ VIRTUAL_CALL_CLASSES = set( ("PPluginBackgroundDestroyer", "parent"), ("PRemotePrintJob", "child"), ("PRemotePrintJob", "parent"), - # PRemotePrintJob, PPrinting, PPrintProgressDialog and PPrintSettingsDialog + # PRemotePrintJob, PPrinting and PPrintSettingsDialog # need to be virtual for --disable-printing builds. ("PPrinting", "child"), ("PPrinting", "parent"), - ("PPrintProgressDialog", "child"), - ("PPrintProgressDialog", "parent"), ("PPrintSettingsDialog", "child"), ("PPrintSettingsDialog", "parent"), ("PQuota", "child"), diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index f77e01544228..f30e2b34f8f4 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2950,7 +2950,6 @@ nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings, NS_ENSURE_STATE(doc); if (NS_WARN_IF(GetIsPrinting())) { - nsPrintJob::CloseProgressDialog(aWebProgressListener); return NS_ERROR_FAILURE; } diff --git a/layout/base/tests/chrome/printpreview_bug396024_helper.xhtml b/layout/base/tests/chrome/printpreview_bug396024_helper.xhtml index 357c140b926f..ab3ca11f00c3 100644 --- a/layout/base/tests/chrome/printpreview_bug396024_helper.xhtml +++ b/layout/base/tests/chrome/printpreview_bug396024_helper.xhtml @@ -40,7 +40,6 @@ function printpreview() { } let settings = Cc["@mozilla.org/gfx/printsettings-service;1"] .getService(Ci.nsIPrintSettingsService).newPrintSettings; - settings.showPrintProgress = false; gWbp.printPreview(settings, frameElts[0].contentWindow, listener); } diff --git a/layout/base/tests/chrome/printpreview_bug482976_helper.xhtml b/layout/base/tests/chrome/printpreview_bug482976_helper.xhtml index 0ce9ca02027f..8acf6e9ce86b 100644 --- a/layout/base/tests/chrome/printpreview_bug482976_helper.xhtml +++ b/layout/base/tests/chrome/printpreview_bug482976_helper.xhtml @@ -41,7 +41,6 @@ function printpreview() { let settings = Cc["@mozilla.org/gfx/printsettings-service;1"] .getService(Ci.nsIPrintSettingsService).newPrintSettings; - settings.showPrintProgress = false; gPrintPreviewWin = frameElts[0].contentWindow.printPreview(settings, listener); gWbp = gPrintPreviewWin.docShell.contentViewer; diff --git a/layout/base/tests/chrome/printpreview_helper.xhtml b/layout/base/tests/chrome/printpreview_helper.xhtml index 776017fa13a5..4c4ea8bb3def 100644 --- a/layout/base/tests/chrome/printpreview_helper.xhtml +++ b/layout/base/tests/chrome/printpreview_helper.xhtml @@ -62,7 +62,6 @@ function printpreview(options = {}) { } var settings = Cc["@mozilla.org/gfx/printsettings-service;1"] .getService(Ci.nsIPrintSettingsService).newPrintSettings; - settings.showPrintProgress = false; settings.printBGColors = true; settings.headerStrLeft = ""; settings.headerStrRight = ""; diff --git a/layout/printing/ipc/RemotePrintJobParent.cpp b/layout/printing/ipc/RemotePrintJobParent.cpp index d2747045e8e5..4f97ae48abba 100644 --- a/layout/printing/ipc/RemotePrintJobParent.cpp +++ b/layout/printing/ipc/RemotePrintJobParent.cpp @@ -267,6 +267,7 @@ mozilla::ipc::IPCResult RemotePrintJobParent::RecvStatusChange( void RemotePrintJobParent::RegisterListener(nsIWebProgressListener* aListener) { MOZ_ASSERT(aListener); + // Our listener is a Promise created by CanonicalBrowsingContext::Print mPrintProgressListeners.AppendElement(aListener); } diff --git a/layout/printing/moz.build b/layout/printing/moz.build index 0a65a13ac35e..b2d01db6a9a2 100644 --- a/layout/printing/moz.build +++ b/layout/printing/moz.build @@ -4,11 +4,6 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -XPIDL_SOURCES += [ - "nsIPrintProgress.idl", - "nsIPrintProgressParams.idl", -] - EXPORTS.mozilla.layout += [ "ipc/RemotePrintJobChild.h", "ipc/RemotePrintJobParent.h", @@ -16,8 +11,6 @@ EXPORTS.mozilla.layout += [ EXPORTS.mozilla.layout.printing += ["DrawEventRecorder.h"] -XPIDL_MODULE = "layout_printing" - UNIFIED_SOURCES += [ "DrawEventRecorder.cpp", "ipc/RemotePrintJobChild.cpp", diff --git a/layout/printing/nsIPrintProgress.idl b/layout/printing/nsIPrintProgress.idl deleted file mode 100644 index 09722133bb6d..000000000000 --- a/layout/printing/nsIPrintProgress.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsIWebProgressListener.idl" - -interface mozIDOMWindowProxy; -interface nsIObserver; -interface nsIPrompt; - -[scriptable, uuid(05f4fb88-e568-4d35-b394-ce0aa3eea6fc)] -interface nsIPrintProgress: nsIWebProgressListener { - - /* Open the progress dialog - you can specify parameters through an xpcom object - */ - void openProgressDialog(in mozIDOMWindowProxy parent, - in string dialogURL, - in nsISupports parameters, - in nsIObserver openDialogObserver, - out boolean notifyOnOpen); - - /* Close the progress dialog */ - void closeProgressDialog(in boolean forceClose); - - /* Register a Web Progress Listener */ - void registerListener(in nsIWebProgressListener listener); - - /* Unregister a Web Progress Listener */ - void unregisterListener(in nsIWebProgressListener listener); - - /* This method is called after the dialog that shows the progress has been shown - */ - void doneIniting(); - - /* Retrieve the prompter, needed to display modal dialog on top of progress dialog */ - nsIPrompt getPrompter(); - - /* Indicated if the user asked to cancel the current process */ - attribute boolean processCanceledByUser; -}; - - diff --git a/layout/printing/nsIPrintProgressParams.idl b/layout/printing/nsIPrintProgressParams.idl deleted file mode 100644 index fa93ea852189..000000000000 --- a/layout/printing/nsIPrintProgressParams.idl +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -[scriptable, uuid(CA89B55B-6FAF-4051-9645-1C03EF5108F8)] -interface nsIPrintProgressParams: nsISupports -{ - attribute AString docTitle; - attribute AString docURL; -}; diff --git a/layout/printing/nsPrintData.cpp b/layout/printing/nsPrintData.cpp index 70b0df2b4d23..405ea56618b9 100644 --- a/layout/printing/nsPrintData.cpp +++ b/layout/printing/nsPrintData.cpp @@ -6,7 +6,6 @@ #include "nsPrintData.h" -#include "nsIPrintProgressParams.h" #include "nsIStringBundle.h" #include "nsIWidget.h" #include "nsPrintObject.h" diff --git a/layout/printing/nsPrintData.h b/layout/printing/nsPrintData.h index 26d40836047d..88ad256ea265 100644 --- a/layout/printing/nsPrintData.h +++ b/layout/printing/nsPrintData.h @@ -18,7 +18,6 @@ #include "nsCOMArray.h" class nsPrintObject; -class nsIPrintProgressParams; class nsIWebProgressListener; //------------------------------------------------------------------------ @@ -50,7 +49,6 @@ class nsPrintData { mozilla::UniquePtr mPrintObject; nsCOMArray mPrintProgressListeners; - nsCOMPtr mPrintProgressParams; // If there is a focused iframe, mSelectionRoot is set to its nsPrintObject. // Otherwise, if there is a selection, it is set to the root nsPrintObject. diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp index 61b9760ef2a5..2d2c71c103eb 100644 --- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -59,13 +59,6 @@ static const char sPrintSettingsServiceContractID[] = // Printing #include "nsIWebBrowserPrint.h" -// Print Preview - -// Print Progress -#include "nsIObserver.h" - -// Print error dialog - // Printing Prompts #include "nsIPrintingPromptService.h" static const char kPrintingPromptService[] = @@ -340,8 +333,7 @@ static nsresult GetDefaultPrintSettings(nsIPrintSettings** aSettings) { //------------------------------------------------------- -NS_IMPL_ISUPPORTS(nsPrintJob, nsIWebProgressListener, nsISupportsWeakReference, - nsIObserver) +NS_IMPL_ISUPPORTS(nsPrintJob, nsIWebProgressListener, nsISupportsWeakReference) //------------------------------------------------------- nsPrintJob::nsPrintJob() = default; @@ -498,7 +490,6 @@ nsresult nsPrintJob::CommonPrint(bool aIsPrintPreview, } else { SetIsPrinting(false); } - if (mProgressDialogIsShown) CloseProgressDialog(aWebProgressListener); if (rv != NS_ERROR_ABORT && rv != NS_ERROR_OUT_OF_MEMORY) { FirePrintingErrorEvent(rv); } @@ -524,12 +515,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview, RefPtr printData = mPrt; if (aIsPrintPreview) { - // The WebProgressListener can be QI'ed to nsIPrintingPromptService - // then that means the progress dialog is already being shown. - nsCOMPtr pps( - do_QueryInterface(aWebProgressListener)); - mProgressDialogIsShown = pps != nullptr; - mIsCreatingPrintPreview = true; // Our new print preview nsPrintData is stored in mPtr until we move it @@ -539,8 +524,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview, SetIsPrintPreview(true); } else { - mProgressDialogIsShown = false; - SetIsPrinting(true); } @@ -784,25 +767,10 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview, MOZ_TRY(EnablePOsForPrinting()); - if (mIsCreatingPrintPreview) { - bool notifyOnInit = false; - ShowPrintProgress(false, notifyOnInit, aDoc); - - if (!notifyOnInit) { - rv = InitPrintDocConstruction(false); - } else { - rv = NS_OK; - } - } else { - bool doNotify; - ShowPrintProgress(true, doNotify, aDoc); - if (!doNotify) { - // Print listener setup... - printData->OnStartPrinting(); - - rv = InitPrintDocConstruction(false); - } + if (!mIsCreatingPrintPreview) { + printData->OnStartPrinting(); } + InitPrintDocConstruction(false); return NS_OK; } @@ -908,66 +876,6 @@ already_AddRefed nsPrintJob::GetCurrentPrintSettings() { //-- Section: Pre-Reflow Methods //----------------------------------------------------------------- -//---------------------------------------------------------------------- -// Set up to use the "pluggable" Print Progress Dialog -void nsPrintJob::ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify, - Document* aDoc) { - // default to not notifying, that if something here goes wrong - // or we aren't going to show the progress dialog we can straight into - // reflowing the doc for printing. - aDoNotify = false; - - // Guarantee that mPrt and the objects it owns won't be deleted. If this - // method shows a progress dialog and spins the event loop. So, mPrt may be - // cleared or recreated. - RefPtr printData = mPrt; - - bool showProgresssDialog = - !mProgressDialogIsShown && StaticPrefs::print_show_print_progress(); - - // Turning off the showing of Print Progress in Prefs overrides - // whether the calling PS desire to have it on or off, so only check PS if - // prefs says it's ok to be on. - if (showProgresssDialog) { - printData->mPrintSettings->GetShowPrintProgress(&showProgresssDialog); - } - - // Now open the service to get the progress dialog - // If we don't get a service, that's ok, then just don't show progress - if (showProgresssDialog) { - nsCOMPtr printPromptService( - do_GetService(kPrintingPromptService)); - if (printPromptService) { - if (mIsForModalWindow) { - // Showing a print progress dialog when printing a modal window - // isn't supported. See bug 301560. - return; - } - - nsPIDOMWindowOuter* domWin = aDoc->GetOriginalDocument()->GetWindow(); - if (!domWin) return; - - nsCOMPtr printProgressListener; - - nsresult rv = printPromptService->ShowPrintProgressDialog( - domWin, printData->mPrintSettings, this, aIsForPrinting, - getter_AddRefs(printProgressListener), - getter_AddRefs(printData->mPrintProgressParams), &aDoNotify); - if (NS_SUCCEEDED(rv)) { - if (printProgressListener) { - printData->mPrintProgressListeners.AppendObject( - printProgressListener); - } - - if (printData->mPrintProgressParams) { - SetURLAndTitleOnProgressParams(printData->mPrintObject, - printData->mPrintProgressParams); - } - } - } - } -} - // static void nsPrintJob::GetDisplayTitleAndURL(Document& aDoc, nsIPrintSettings* aSettings, @@ -2147,10 +2055,6 @@ nsresult nsPrintJob::DoPrint(const UniquePtr& aPO) { return NS_ERROR_FAILURE; } - if (printData->mPrintProgressParams) { - SetURLAndTitleOnProgressParams(aPO, printData->mPrintProgressParams); - } - { // Ask the page sequence frame to print all the pages nsPageSequenceFrame* seqFrame = poPresShell->GetPageSequenceFrame(); @@ -2229,48 +2133,6 @@ nsresult nsPrintJob::DoPrint(const UniquePtr& aPO) { return NS_OK; } -//--------------------------------------------------------------------- -void nsPrintJob::SetURLAndTitleOnProgressParams( - const UniquePtr& aPO, nsIPrintProgressParams* aParams) { - NS_ASSERTION(aPO, "Must have valid nsPrintObject"); - NS_ASSERTION(aParams, "Must have valid nsIPrintProgressParams"); - - if (!aPO || !aPO->mDocShell || !aParams) { - return; - } - const uint32_t kTitleLength = 64; - - nsAutoString docTitleStr; - nsAutoString docURLStr; - GetDisplayTitleAndURL(*aPO->mDocument, mPrt->mPrintSettings, - DocTitleDefault::eDocURLElseFallback, docTitleStr, - docURLStr); - - // Make sure the Titles & URLS don't get too long for the progress dialog - EllipseLongString(docTitleStr, kTitleLength, false); - EllipseLongString(docURLStr, kTitleLength, true); - - aParams->SetDocTitle(docTitleStr); - aParams->SetDocURL(docURLStr); -} - -//--------------------------------------------------------------------- -void nsPrintJob::EllipseLongString(nsAString& aStr, const uint32_t aLen, - bool aDoFront) { - // Make sure the URLS don't get too long for the progress dialog - if (aLen >= 3 && aStr.Length() > aLen) { - if (aDoFront) { - nsAutoString newStr; - newStr.AppendLiteral("..."); - newStr += Substring(aStr, aStr.Length() - (aLen - 3), aLen - 3); - aStr = newStr; - } else { - aStr.SetLength(aLen - 3); - aStr.AppendLiteral("..."); - } - } -} - //------------------------------------------------------- bool nsPrintJob::PrePrintSheet() { NS_ASSERTION(mPageSeqFrame.IsAlive(), "mPageSeqFrame is not alive!"); @@ -2589,18 +2451,6 @@ nsPrintObject* nsPrintJob::FindSmallestSTF() { //-- Section: Finishing up or Cleaning up //----------------------------------------------------------------- -//----------------------------------------------------------------- -void nsPrintJob::CloseProgressDialog( - nsIWebProgressListener* aWebProgressListener) { - if (aWebProgressListener) { - aWebProgressListener->OnStateChange( - nullptr, nullptr, - nsIWebProgressListener::STATE_STOP | - nsIWebProgressListener::STATE_IS_DOCUMENT, - NS_OK); - } -} - //----------------------------------------------------------------- nsresult nsPrintJob::FinishPrintPreview() { nsresult rv = NS_OK; @@ -2707,27 +2557,6 @@ nsresult nsPrintJob::StartPagePrintTimer(const UniquePtr& aPO) { return mPagePrintTimer->Start(aPO.get()); } -/*=============== nsIObserver Interface ======================*/ -MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP nsPrintJob::Observe( - nsISupports* aSubject, const char* aTopic, const char16_t* aData) { - // We expect to be called by nsIPrintingPromptService after we were passed to - // it by via the nsIPrintingPromptService::ShowPrintProgressDialog call in - // ShowPrintProgress. Once it has opened the progress dialog it calls this - // method, passing null as the topic. - - if (aTopic) { - return NS_OK; - } - - nsresult rv = InitPrintDocConstruction(true); - if (!mIsDoingPrinting && mPrtPreview) { - RefPtr printDataOfPrintPreview = mPrtPreview; - printDataOfPrintPreview->OnEndPrinting(); - } - - return rv; -} - //--------------------------------------------------------------- //-- PLEvent Notification //--------------------------------------------------------------- diff --git a/layout/printing/nsPrintJob.h b/layout/printing/nsPrintJob.h index 3eb6f5e57f4f..23a79f2020bd 100644 --- a/layout/printing/nsPrintJob.h +++ b/layout/printing/nsPrintJob.h @@ -18,13 +18,11 @@ #include "nsWeakReference.h" // Interfaces -#include "nsIObserver.h" #include "nsIWebProgress.h" #include "nsIWebProgressListener.h" // Classes class nsIFrame; -class nsIPrintProgressParams; class nsIPrintSettings; class nsPrintData; class nsPagePrintTimer; @@ -49,24 +47,18 @@ class PrintPreviewResultInfo; * A print job may be instantiated either for printing to an actual physical * printer, or for creating a print preview. */ -class nsPrintJob final : public nsIObserver, - public nsIWebProgressListener, +class nsPrintJob final : public nsIWebProgressListener, public nsSupportsWeakReference { using Document = mozilla::dom::Document; using PrintPreviewResolver = std::function; public: - static void CloseProgressDialog(nsIWebProgressListener* aWebProgressListener); - nsPrintJob(); // nsISupports interface... NS_DECL_ISUPPORTS - // nsIObserver - NS_DECL_NSIOBSERVER - NS_DECL_NSIWEBPROGRESSLISTENER /** @@ -182,11 +174,6 @@ class nsPrintJob final : public nsIObserver, nsresult ReflowPrintObject(const mozilla::UniquePtr& aPO); void CalcNumPrintablePages(int32_t& aNumPages); - void ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify, Document* aDoc); - void SetURLAndTitleOnProgressParams( - const mozilla::UniquePtr& aPO, - nsIPrintProgressParams* aParams); - void EllipseLongString(nsAString& aStr, const uint32_t aLen, bool aDoFront); nsresult StartPagePrintTimer(const mozilla::UniquePtr& aPO); @@ -297,7 +284,6 @@ class nsPrintJob final : public nsIObserver, bool mIsCreatingPrintPreview = false; bool mIsDoingPrinting = false; bool mHasEverPrinted = false; - bool mProgressDialogIsShown = false; bool mDidLoadDataForPrinting = false; bool mDoingInitialReflow = false; bool mIsDestroying = false; diff --git a/layout/tools/reftest/reftest.jsm b/layout/tools/reftest/reftest.jsm index 310b2363ee72..92fd921a562b 100644 --- a/layout/tools/reftest/reftest.jsm +++ b/layout/tools/reftest/reftest.jsm @@ -1715,7 +1715,6 @@ function RecvStartPrint(isPrintSelection, printRange) let PSSVC = Cc["@mozilla.org/gfx/printsettings-service;1"].getService(Ci.nsIPrintSettingsService); let ps = PSSVC.newPrintSettings; ps.printSilent = true; - ps.showPrintProgress = false; ps.printBGImages = true; ps.printBGColors = true; ps.unwriteableMarginTop = 0; diff --git a/remote/cdp/domains/parent/Page.jsm b/remote/cdp/domains/parent/Page.jsm index e97beadf4055..6429868d5097 100644 --- a/remote/cdp/domains/parent/Page.jsm +++ b/remote/cdp/domains/parent/Page.jsm @@ -576,7 +576,6 @@ class Page extends Domain { printSettings.printerName = ""; printSettings.printSilent = true; printSettings.printToFile = true; - printSettings.showPrintProgress = false; printSettings.toFileName = filePath; printSettings.paperSizeUnit = Ci.nsIPrintSettings.kPaperSizeInches; diff --git a/remote/marionette/print.js b/remote/marionette/print.js index df963c535043..68310c819baf 100644 --- a/remote/marionette/print.js +++ b/remote/marionette/print.js @@ -71,7 +71,6 @@ function getPrintSettings(settings, filePath) { printSettings.printerName = "marionette"; printSettings.printSilent = true; printSettings.printToFile = true; - printSettings.showPrintProgress = false; printSettings.toFileName = filePath; // Setting the paperSizeUnit to kPaperSizeMillimeters doesn't work on mac diff --git a/toolkit/actors/PrintingChild.jsm b/toolkit/actors/PrintingChild.jsm index 5df11d58f4f7..815cd685f0a8 100644 --- a/toolkit/actors/PrintingChild.jsm +++ b/toolkit/actors/PrintingChild.jsm @@ -360,9 +360,6 @@ class PrintingChild extends JSWindowActorChild { let contentWindow = browsingContext.window; let printSettings = this.getPrintSettings(lastUsedPrinterName); - // Disable the progress dialog for generating previews. - printSettings.showPrintProgress = 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 // "about:blank" as its URI. diff --git a/toolkit/actors/PrintingParent.jsm b/toolkit/actors/PrintingParent.jsm index 00baca696c44..333866f714e3 100644 --- a/toolkit/actors/PrintingParent.jsm +++ b/toolkit/actors/PrintingParent.jsm @@ -33,7 +33,6 @@ class PrintingParent extends JSWindowActorParent { return undefined; } - let listener = PrintUtils._webProgressPP?.value; let data = message.data; switch (message.name) { @@ -68,29 +67,11 @@ class PrintingParent extends JSWindowActorParent { } case "Printing:Preview:ProgressChange": { - if (!PrintUtils._webProgressPP.value) { - // We somehow didn't get a nsIWebProgressListener to be updated... - // I guess there's nothing to do. - return undefined; - } - - return listener.onProgressChange( - null, - null, - data.curSelfProgress, - data.maxSelfProgress, - data.curTotalProgress, - data.maxTotalProgress - ); + // nothing to do now we don't implement a print progress dialog + return undefined; } case "Printing:Preview:StateChange": { - if (!PrintUtils._webProgressPP.value) { - // We somehow didn't get a nsIWebProgressListener to be updated... - // I guess there's nothing to do. - return undefined; - } - if (data.stateFlags & Ci.nsIWebProgressListener.STATE_STOP) { // Strangely, the printing engine sends 2 STATE_STOP messages when // print preview is finishing. One has the STATE_IS_DOCUMENT flag, @@ -104,7 +85,8 @@ class PrintingParent extends JSWindowActorParent { printPreviewTB.disableUpdateTriggers(false); } - return listener.onStateChange(null, null, data.stateFlags, data.status); + // nothing else to do now we don't implement a print progress dialog + return undefined; } } diff --git a/toolkit/components/browser/nsIPrintingPromptService.idl b/toolkit/components/browser/nsIPrintingPromptService.idl index afc22a4f5315..f737ddf89a9f 100644 --- a/toolkit/components/browser/nsIPrintingPromptService.idl +++ b/toolkit/components/browser/nsIPrintingPromptService.idl @@ -8,7 +8,6 @@ #include "nsISupports.idl" #include "nsIWebBrowserPrint.idl" #include "nsIWebProgressListener.idl" -#include "nsIPrintProgressParams.idl" #include "nsIPrintSettings.idl" #include "nsIObserver.idl" @@ -34,7 +33,6 @@ interface nsIPrintingPromptService : nsISupports * * Defaults for platform service: * showPrintDialog - displays a native dialog - * showPrintProgressDialog - displays a XUL dialog * showPageSetupDialog - displays a XUL dialog * * Summary for Windows Embedders: @@ -67,14 +65,12 @@ interface nsIPrintingPromptService : nsISupports * The toolkit will display the native print dialog. * * Mac OSX: showPrintDialog - displays a native dialog - * showPrintProgressDialog - not implemented (provided by OS) * showPageSetupDialog - displays a native dialog * * GTK: There are no native dialog for GTK. * * Defaults for platform service: * showPrintDialog - displays a native dialog - * showPrintProgressDialog - displays a XUL dialog * showPageSetupDialog - displays a native dialog * */ @@ -92,28 +88,6 @@ interface nsIPrintingPromptService : nsISupports void showPrintDialog(in mozIDOMWindowProxy parent, in nsIPrintSettings printSettings); - /** - * Shows the print progress dialog - * - * @param parent - a DOM windows the dialog will be parented to - * @param printSettings - PrintSettings for print "job" - * @param openDialogObserver - an observer that will be notifed when the dialog is opened - * @param isForPrinting - true - for printing, false for print preview - * @param webProgressListener - additional listener can be registered for progress notifications - * @param printProgressParams - parameter object for passing progress state - * @param notifyOnOpen - this indicates that the observer will be notified when the progress - * dialog has been opened. If false is returned it means the observer - * (usually the caller) shouldn't wait - * For Print Preview Progress there is intermediate progress - */ - void showPrintProgressDialog(in mozIDOMWindowProxy parent, - in nsIPrintSettings printSettings, - in nsIObserver openDialogObserver, - in boolean isForPrinting, - out nsIWebProgressListener webProgressListener, - out nsIPrintProgressParams printProgressParams, - out boolean notifyOnOpen); - /** * Shows the print page setup dialog * diff --git a/toolkit/components/printing/content/print.js b/toolkit/components/printing/content/print.js index b3ed05f4a8b1..f4e1a7f2bcd8 100644 --- a/toolkit/components/printing/content/print.js +++ b/toolkit/components/printing/content/print.js @@ -296,7 +296,6 @@ var PrintEventHandler = { this.settings.printerName == PrintUtils.SAVE_TO_PDF_PRINTER ? PrintUtils.getPrintSettings(this.viewSettings.defaultSystemPrinter) : this.settings.clone(); - settings.showPrintProgress = false; // Update the settings print options on whether there is a selection since // getPrintSettings won't have the correct value. settings.isPrintSelectionRBEnabled = this.hasSelection; @@ -415,7 +414,6 @@ var PrintEventHandler = { try { // We'll provide our own progress indicator. - this.settings.showPrintProgress = false; let l10nId = settings.printerName == PrintUtils.SAVE_TO_PDF_PRINTER ? "printui-print-progress-indicator-saving" @@ -803,9 +801,6 @@ var PrintEventHandler = { async _updatePrintPreview() { let { settings } = this; - // We never want the progress dialog to show - settings.showPrintProgress = false; - const isFirstCall = !this.printInitiationTime; if (isFirstCall) { let params = new URLSearchParams(location.search); diff --git a/toolkit/components/printing/content/printPreviewProgress.js b/toolkit/components/printing/content/printPreviewProgress.js deleted file mode 100644 index 783f434a343f..000000000000 --- a/toolkit/components/printing/content/printPreviewProgress.js +++ /dev/null @@ -1,152 +0,0 @@ -// -*- indent-tabs-mode: nil; js-indent-level: 2 -*- - -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// dialog is just an array we'll use to store various properties from the dialog document... -var dialog; - -// the printProgress is a nsIPrintProgress object -var printProgress = null; - -// random global variables... -var targetFile; - -var docTitle = ""; -var docURL = ""; -var progressParams = null; - -function ellipseString(aStr, doFront) { - if (!aStr) { - return ""; - } - - if ( - aStr.length > 3 && - (aStr.substr(0, 3) == "..." || aStr.substr(aStr.length - 4, 3) == "...") - ) { - return aStr; - } - - var fixedLen = 64; - if (aStr.length <= fixedLen) { - return aStr; - } - - if (doFront) { - return "..." + aStr.substr(aStr.length - fixedLen, fixedLen); - } - - return aStr.substr(0, fixedLen) + "..."; -} - -// all progress notifications are done through the nsIWebProgressListener implementation... -var progressListener = { - onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { - if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) { - window.close(); - } - }, - - onProgressChange( - aWebProgress, - aRequest, - aCurSelfProgress, - aMaxSelfProgress, - aCurTotalProgress, - aMaxTotalProgress - ) { - if (!progressParams) { - return; - } - var docTitleStr = ellipseString(progressParams.docTitle, false); - if (docTitleStr != docTitle) { - docTitle = docTitleStr; - dialog.title.value = docTitle; - } - var docURLStr = ellipseString(progressParams.docURL, true); - if (docURLStr != docURL && dialog.title != null) { - docURL = docURLStr; - if (docTitle == "") { - dialog.title.value = docURLStr; - } - } - }, - - onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {}, - onSecurityChange(aWebProgress, aRequest, state) {}, - onContentBlockingEvent(aWebProgress, aRequest, event) {}, - - onStatusChange(aWebProgress, aRequest, aStatus, aMessage) { - if (aMessage) { - dialog.title.setAttribute("value", aMessage); - } - }, - - QueryInterface: ChromeUtils.generateQI([ - "nsIWebProgressListener", - "nsISupportsWeakReference", - ]), -}; - -function onLoad() { - // Set global variables. - printProgress = window.arguments[0]; - if (window.arguments[1]) { - progressParams = window.arguments[1].QueryInterface( - Ci.nsIPrintProgressParams - ); - if (progressParams) { - docTitle = ellipseString(progressParams.docTitle, false); - docURL = ellipseString(progressParams.docURL, true); - } - } - - if (!printProgress) { - dump("Invalid argument to printPreviewProgress.xhtml\n"); - window.close(); - return; - } - - dialog = {}; - dialog.strings = []; - dialog.title = document.getElementById("dialog.title"); - dialog.titleLabel = document.getElementById("dialog.titleLabel"); - - dialog.title.value = docTitle; - - // set our web progress listener on the helper app launcher - printProgress.registerListener(progressListener); - - // We need to delay the set title else dom will overwrite it - window.setTimeout(doneIniting, 100); -} - -function onUnload() { - if (!printProgress) { - return; - } - try { - printProgress.unregisterListener(progressListener); - printProgress = null; - } catch (e) {} -} - -// If the user presses cancel, tell the app launcher and close the dialog... -function onCancel() { - // Cancel app launcher. - try { - printProgress.processCanceledByUser = true; - } catch (e) { - return true; - } - - // don't Close up dialog by returning false, the backend will close the dialog when everything will be aborted. - return false; -} - -function doneIniting() { - // called by function timeout in onLoad - printProgress.doneIniting(); -} diff --git a/toolkit/components/printing/content/printPreviewProgress.xhtml b/toolkit/components/printing/content/printPreviewProgress.xhtml deleted file mode 100644 index 02ab68b07339..000000000000 --- a/toolkit/components/printing/content/printPreviewProgress.xhtml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - -