Bug 1745452 - Remove the print progress dialog code. r=mstriemer,bobowen,webdriver-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D133500
This commit is contained in:
Jonathan Watt 2021-12-16 15:12:33 +00:00
parent a7b97dd162
commit ac90ddff59
51 changed files with 17 additions and 1981 deletions

View File

@ -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

View File

@ -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;

View File

@ -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"),

View File

@ -2950,7 +2950,6 @@ nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings,
NS_ENSURE_STATE(doc);
if (NS_WARN_IF(GetIsPrinting())) {
nsPrintJob::CloseProgressDialog(aWebProgressListener);
return NS_ERROR_FAILURE;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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 = "";

View File

@ -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);
}

View File

@ -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",

View File

@ -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;
};

View File

@ -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;
};

View File

@ -6,7 +6,6 @@
#include "nsPrintData.h"
#include "nsIPrintProgressParams.h"
#include "nsIStringBundle.h"
#include "nsIWidget.h"
#include "nsPrintObject.h"

View File

@ -18,7 +18,6 @@
#include "nsCOMArray.h"
class nsPrintObject;
class nsIPrintProgressParams;
class nsIWebProgressListener;
//------------------------------------------------------------------------
@ -50,7 +49,6 @@ class nsPrintData {
mozilla::UniquePtr<nsPrintObject> mPrintObject;
nsCOMArray<nsIWebProgressListener> mPrintProgressListeners;
nsCOMPtr<nsIPrintProgressParams> 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.

View File

@ -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<nsPrintData> printData = mPrt;
if (aIsPrintPreview) {
// The WebProgressListener can be QI'ed to nsIPrintingPromptService
// then that means the progress dialog is already being shown.
nsCOMPtr<nsIPrintingPromptService> 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<nsIPrintSettings> 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<nsPrintData> 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<nsIPrintingPromptService> 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<nsIWebProgressListener> 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<nsPrintObject>& 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<nsPrintObject>& aPO) {
return NS_OK;
}
//---------------------------------------------------------------------
void nsPrintJob::SetURLAndTitleOnProgressParams(
const UniquePtr<nsPrintObject>& 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<nsPrintObject>& 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<nsPrintData> printDataOfPrintPreview = mPrtPreview;
printDataOfPrintPreview->OnEndPrinting();
}
return rv;
}
//---------------------------------------------------------------
//-- PLEvent Notification
//---------------------------------------------------------------

View File

@ -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<void(const mozilla::dom::PrintPreviewResultInfo&)>;
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<nsPrintObject>& aPO);
void CalcNumPrintablePages(int32_t& aNumPages);
void ShowPrintProgress(bool aIsForPrinting, bool& aDoNotify, Document* aDoc);
void SetURLAndTitleOnProgressParams(
const mozilla::UniquePtr<nsPrintObject>& aPO,
nsIPrintProgressParams* aParams);
void EllipseLongString(nsAString& aStr, const uint32_t aLen, bool aDoFront);
nsresult StartPagePrintTimer(const mozilla::UniquePtr<nsPrintObject>& 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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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;
}
}

View File

@ -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
*

View File

@ -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);

View File

@ -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();
}

View File

@ -1,34 +0,0 @@
<?xml version="1.0"?>
<!-- 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/. -->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
data-l10n-id="print-preview-window"
style="width: 36em;"
oncancel="onCancel()"
onload="onLoad()"
onunload="onUnload()">
<dialog buttons="cancel">
<linkset>
<html:link rel="localization" href="toolkit/printing/printDialogs.ftl"/>
</linkset>
<script src="chrome://global/content/printPreviewProgress.js"/>
<box flex="1" style="display: grid; grid-template-columns: min-content max-content; grid-template-rows: max-content max-content;">
<!-- First row -->
<label id="dialog.titleLabel" data-l10n-id="print-title" style="justify-self: end;"/>
<label id="dialog.title"/>
<!-- Second row -->
<label id="dialog.progressLabel" data-l10n-id="print-progress" style="justify-self: end;"/>
<label id="dialog.progressSpaces" data-l10n-id="print-preparing"/>
</box>
</dialog>
</window>

View File

@ -1,230 +0,0 @@
// -*- tab-width: 2; 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/. */
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
// 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;
var switchUI = true;
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) {
if (doFront) {
var endStr = aStr.substr(aStr.length - fixedLen, fixedLen);
return "..." + endStr;
}
var frontStr = aStr.substr(0, fixedLen);
return frontStr + "...";
}
return aStr;
}
// all progress notifications are done through the nsIWebProgressListener implementation...
var progressListener = {
onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
// Put progress meter in undetermined mode.
dialog.progress.removeAttribute("value");
}
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
// we are done printing
// Indicate completion in title area.
document.l10n.setAttributes(dialog.title, "print-complete");
// Put progress meter at 100%.
dialog.progress.setAttribute("value", 100);
document.l10n.setAttributes(dialog.progressText, "print-percent", {
percent: 100,
});
if (Services.focus.activeWindow == window) {
// This progress dialog is the currently active window. In
// this case we need to make sure that some other window
// gets focus before we close this dialog to work around the
// buggy Windows XP Fax dialog, which ends up parenting
// itself to the currently focused window and is unable to
// survive that window going away. What happens without this
// opener.focus() call on Windows XP is that the fax dialog
// is opened only to go away when this dialog actually
// closes (which can happen asynchronously, so the fax
// dialog just flashes once and then goes away), so w/o this
// fix, it's impossible to fax on Windows XP w/o manually
// switching focus to another window (or holding on to the
// progress dialog with the mouse long enough).
opener.focus();
}
window.close();
}
},
onProgressChange(
aWebProgress,
aRequest,
aCurSelfProgress,
aMaxSelfProgress,
aCurTotalProgress,
aMaxTotalProgress
) {
if (switchUI) {
dialog.tempLabel.hidden = true;
dialog.progressBox.hidden = false;
switchUI = false;
}
if (progressParams) {
var docTitleStr = ellipseString(progressParams.docTitle, false);
if (docTitleStr != docTitle) {
docTitle = docTitleStr;
dialog.title.value = docTitle;
}
var docURLStr = progressParams.docURL;
if (docURLStr != docURL && dialog.title != null) {
docURL = docURLStr;
if (docTitle == "") {
dialog.title.value = ellipseString(docURLStr, true);
}
}
}
// Calculate percentage.
var percent;
if (aMaxTotalProgress > 0) {
percent = Math.round((aCurTotalProgress * 100) / aMaxTotalProgress);
if (percent > 100) {
percent = 100;
}
// Advance progress meter.
dialog.progress.setAttribute("value", percent);
// Update percentage label on progress meter.
document.l10n.setAttributes(dialog.progressText, "print-percent", {
percent,
});
} else {
// Progress meter should be barber-pole in this case.
dialog.progress.removeAttribute("value");
// Update percentage label on progress meter.
dialog.progressText.setAttribute("value", "");
}
},
onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
// we can ignore this notification
},
onStatusChange(aWebProgress, aRequest, aStatus, aMessage) {
if (aMessage != "") {
dialog.title.setAttribute("value", aMessage);
}
},
onSecurityChange(aWebProgress, aRequest, state) {
// we can ignore this notification
},
onContentBlockingEvent(aWebProgress, aRequest, event) {
// we can ignore this notification
},
QueryInterface: ChromeUtils.generateQI([
"nsIWebProgressListener",
"nsISupportsWeakReference",
]),
};
function loadDialog() {}
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 printProgress.xhtml\n");
window.close();
return;
}
dialog = {};
dialog.strings = [];
dialog.title = document.getElementById("dialog.title");
dialog.titleLabel = document.getElementById("dialog.titleLabel");
dialog.progress = document.getElementById("dialog.progress");
dialog.progressBox = document.getElementById("dialog.progressBox");
dialog.progressText = document.getElementById("dialog.progressText");
dialog.progressLabel = document.getElementById("dialog.progressLabel");
dialog.tempLabel = document.getElementById("dialog.tempLabel");
dialog.progressBox.hidden = true;
document.l10n.setAttributes(dialog.tempLabel, "print-preparing");
dialog.title.value = docTitle;
// Fill dialog.
loadDialog();
document.addEventListener("dialogcancel", onCancel);
// 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, 500);
}
function onUnload() {
if (printProgress) {
try {
printProgress.unregisterListener(progressListener);
printProgress = null;
} catch (exception) {}
}
}
// If the user presses cancel, tell the app launcher and close the dialog.
function onCancel() {
// Cancel app launcher.
try {
printProgress.processCanceledByUser = true;
} catch (exception) {}
}
function doneIniting() {
printProgress.doneIniting();
}

View File

@ -1,47 +0,0 @@
<?xml version="1.0"?>
<!-- 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/. -->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
data-l10n-id="print-window"
style="width: 36em;"
onload="onLoad()"
onunload="onUnload()">
<dialog buttons="cancel">
<linkset>
<html:link rel="localization" href="toolkit/printing/printDialogs.ftl"/>
</linkset>
<script src="chrome://global/content/printProgress.js"/>
<box style="display: grid; grid-template-columns: auto 1fr auto;" flex="1">
<!-- First row -->
<hbox pack="end">
<label id="dialog.titleLabel" data-l10n-id="print-title"/>
</hbox>
<label id="dialog.title"/>
<spacer/>
<!-- Second row -->
<hbox pack="end">
<html:label id="dialog.progressLabel" for="dialog.progress"
style="margin-right: 1em;" data-l10n-id="progress"/>
</hbox>
<box>
<label id="dialog.tempLabel" data-l10n-id="print-preparing"/>
<vbox pack="center" id="dialog.progressBox" flex="1">
<html:progress id="dialog.progress" value="0" max="100" style="width: 100%;"/>
</vbox>
</box>
<hbox pack="end" style="min-width: 2.5em;">
<label id="dialog.progressText"/>
</hbox>
</box>
</dialog>
</window>

View File

@ -454,54 +454,14 @@ var PrintUtils = {
? this._listener.getSimplifiedPrintPreviewBrowser()
: this._listener.getPrintPreviewBrowser();
this._sourceBrowser.collapsed = true;
// If the user transits too quickly within preview and we have a pending
// progress dialog, we will close it before opening a new one.
this.ensureProgressDialogClosed();
}
this._webProgressPP = {};
let ppParams = {};
let notifyOnOpen = {};
let printSettings = this.getPrintSettings();
// Here we get the PrintingPromptService so we can display the PP Progress from script
// For the browser implemented via XUL with the PP toolbar we cannot let it be
// automatically opened from the print engine because the XUL scrollbars in the PP window
// will layout before the content window and a crash will occur.
// Doing it all from script, means it lays out before hand and we can let printing do its own thing
let PPROMPTSVC = Cc[
"@mozilla.org/embedcomp/printingprompt-service;1"
].getService(Ci.nsIPrintingPromptService);
let promise = new Promise((resolve, reject) => {
this._onEntered.push({ resolve, reject });
});
// just in case we are already printing,
// an error code could be returned if the Progress Dialog is already displayed
try {
PPROMPTSVC.showPrintProgressDialog(
window,
printSettings,
this._obsPP,
false,
this._webProgressPP,
ppParams,
notifyOnOpen
);
if (ppParams.value) {
ppParams.value.docTitle = this._originalTitle;
ppParams.value.docURL = this._originalURL;
}
this._enterPrintPreview();
// this tells us whether we should continue on with PP or
// wait for the callback via the observer
if (!notifyOnOpen.value.valueOf() || this._webProgressPP.value == null) {
this._enterPrintPreview();
}
} catch (e) {
this._enterPrintPreview();
}
return promise;
},
@ -509,7 +469,6 @@ var PrintUtils = {
_listener: null,
_closeHandlerPP: null,
_webProgressPP: null,
_sourceBrowser: null,
_originalTitle: "",
_originalURL: "",
@ -643,26 +602,6 @@ var PrintUtils = {
return printSettings;
},
// This observer is called once the progress dialog has been "opened"
_obsPP: {
observe(aSubject, aTopic, aData) {
// Only process a null topic which means the progress dialog is open.
if (aTopic) {
return;
}
// delay the print preview to show the content of the progress dialog
setTimeout(function() {
PrintUtils._enterPrintPreview();
}, 0);
},
QueryInterface: ChromeUtils.generateQI([
"nsIObserver",
"nsISupportsWeakReference",
]),
},
get shouldSimplify() {
return this._shouldSimplify;
},
@ -689,10 +628,7 @@ var PrintUtils = {
_enterPrintPreview() {
// Send a message to the print preview browser to initialize
// print preview. If we happen to have gotten a print preview
// progress listener from nsIPrintingPromptService.showPrintProgressDialog
// in printPreview, we add listeners to feed that progress
// listener.
// print preview.
let ppBrowser = this._shouldSimplify
? this._listener.getSimplifiedPrintPreviewBrowser()
: this._listener.getPrintPreviewBrowser();
@ -709,12 +645,7 @@ var PrintUtils = {
}
this._currentPPBrowser = ppBrowser;
let waitForPrintProgressToEnableToolbar = false;
if (this._webProgressPP.value) {
waitForPrintProgressToEnableToolbar = true;
}
gPendingPrintPreviews.set(ppBrowser, waitForPrintProgressToEnableToolbar);
gPendingPrintPreviews.set(ppBrowser, false);
// If we happen to have gotten simplify page checked, we will lazily
// instantiate a new tab that parses the original page using ReaderMode
@ -947,8 +878,6 @@ var PrintUtils = {
this.setSimplifiedMode(false);
this.ensureProgressDialogClosed();
this._listener.onExit();
this._originalTitle = "";
@ -1002,21 +931,6 @@ var PrintUtils = {
aEvent.stopPropagation();
}
},
/**
* If there's a printing or print preview progress dialog displayed, force
* it to close now.
*/
ensureProgressDialogClosed() {
if (this._webProgressPP && this._webProgressPP.value) {
this._webProgressPP.value.onStateChange(
null,
null,
Ci.nsIWebProgressListener.STATE_STOP,
0
);
}
},
};
class PrintPreview extends MozElements.BaseControl {

View File

@ -3,15 +3,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
toolkit.jar:
#ifndef XP_MACOSX
#ifdef XP_WIN
content/global/printPageSetup.js (content/printPageSetup.js)
content/global/printPageSetup.xhtml (content/printPageSetup.xhtml)
#endif
content/global/printPreviewProgress.js (content/printPreviewProgress.js)
content/global/printPreviewProgress.xhtml (content/printPreviewProgress.xhtml)
content/global/printProgress.js (content/printProgress.js)
content/global/printProgress.xhtml (content/printProgress.xhtml)
#endif
content/global/printPreviewPagination.js (content/printPreviewPagination.js)
content/global/printPreviewToolbar.js (content/printPreviewToolbar.js)

View File

@ -1,36 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* 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 protocol PPrinting;
namespace mozilla {
namespace embedding {
protocol PPrintProgressDialog
{
manager PPrinting;
parent:
async StateChange(long stateFlags,
nsresult status);
async ProgressChange(long curSelfProgress,
long maxSelfProgress,
long curTotalProgress,
long maxTotalProgress);
async DocTitleChange(nsString newTitle);
async DocURLChange(nsString newURL);
async __delete__();
child:
async DialogOpened();
async CancelledCurrentJob();
};
} // namespace embedding
} // namespace mozilla

View File

@ -6,7 +6,6 @@
include PPrintingTypes;
include protocol PContent;
include protocol PBrowser;
include protocol PPrintProgressDialog;
include protocol PPrintSettingsDialog;
include protocol PRemotePrintJob;
@ -16,21 +15,14 @@ namespace embedding {
sync protocol PPrinting
{
manager PContent;
manages PPrintProgressDialog;
manages PPrintSettingsDialog;
manages PRemotePrintJob;
parent:
async ShowProgress(PBrowser browser,
PPrintProgressDialog printProgressDialog,
nullable PRemotePrintJob remotePrintJob,
bool isForPrinting);
async ShowPrintDialog(PPrintSettingsDialog dialog,
nullable PBrowser browser,
PrintData settings);
async PPrintProgressDialog();
async PPrintSettingsDialog();
sync SavePrintSettings(PrintData settings, bool usePrinterNamePrefix,

View File

@ -47,7 +47,6 @@ struct PrintData {
bool isCancelled;
bool printSilent;
bool shrinkToFit;
bool showPrintProgress;
nsString paperId;
double paperWidth;

View File

@ -1,128 +0,0 @@
/* 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 "mozilla/Unused.h"
#include "nsIObserver.h"
#include "nsIPrintProgressParams.h"
#include "PrintProgressDialogChild.h"
class nsIWebProgress;
class nsIRequest;
using mozilla::Unused;
namespace mozilla {
namespace embedding {
NS_IMPL_ISUPPORTS(PrintProgressDialogChild, nsIWebProgressListener,
nsIPrintProgressParams)
PrintProgressDialogChild::PrintProgressDialogChild(
nsIObserver* aOpenObserver, nsIPrintSettings* aPrintSettings)
: mOpenObserver(aOpenObserver), mPrintSettings(aPrintSettings) {}
PrintProgressDialogChild::~PrintProgressDialogChild() {
// When the printing engine stops supplying information about printing
// progress, it'll drop references to us and destroy us. We need to signal
// the parent to decrement its refcount, as well as prevent it from attempting
// to contact us further.
Unused << Send__delete__(this);
}
mozilla::ipc::IPCResult PrintProgressDialogChild::RecvDialogOpened() {
// nsPrintJob's observer, which we're reporting to here, doesn't care
// what gets passed as the subject, topic or data, so we'll just send
// nullptrs.
mOpenObserver->Observe(nullptr, nullptr, nullptr);
return IPC_OK();
}
mozilla::ipc::IPCResult PrintProgressDialogChild::RecvCancelledCurrentJob() {
if (mPrintSettings) {
mPrintSettings->SetIsCancelled(true);
}
return IPC_OK();
}
// nsIWebProgressListener
NS_IMETHODIMP
PrintProgressDialogChild::OnStateChange(nsIWebProgress* aProgress,
nsIRequest* aRequest,
uint32_t aStateFlags,
nsresult aStatus) {
Unused << SendStateChange(aStateFlags, aStatus);
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::OnProgressChange(nsIWebProgress* aProgress,
nsIRequest* aRequest,
int32_t aCurSelfProgress,
int32_t aMaxSelfProgress,
int32_t aCurTotalProgress,
int32_t aMaxTotalProgress) {
Unused << SendProgressChange(aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::OnLocationChange(nsIWebProgress* aProgress,
nsIRequest* aRequest, nsIURI* aURI,
uint32_t aFlags) {
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::OnStatusChange(nsIWebProgress* aProgress,
nsIRequest* aRequest, nsresult aStatus,
const char16_t* aMessage) {
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::OnSecurityChange(nsIWebProgress* aProgress,
nsIRequest* aRequest,
uint32_t aState) {
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::OnContentBlockingEvent(nsIWebProgress* aProgress,
nsIRequest* aRequest,
uint32_t aEvent) {
return NS_OK;
}
// nsIPrintProgressParams
NS_IMETHODIMP
PrintProgressDialogChild::GetDocTitle(nsAString& aDocTitle) {
aDocTitle = mDocTitle;
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::SetDocTitle(const nsAString& aDocTitle) {
mDocTitle = aDocTitle;
Unused << SendDocTitleChange(PromiseFlatString(aDocTitle));
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::GetDocURL(nsAString& aDocURL) {
aDocURL = mDocURL;
return NS_OK;
}
NS_IMETHODIMP
PrintProgressDialogChild::SetDocURL(const nsAString& aDocURL) {
mDocURL = aDocURL;
Unused << SendDocURLChange(PromiseFlatString(aDocURL));
return NS_OK;
}
} // namespace embedding
} // namespace mozilla

View File

@ -1,44 +0,0 @@
/* 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/. */
#ifndef mozilla_embedding_PrintProgressDialogChild_h
#define mozilla_embedding_PrintProgressDialogChild_h
#include "mozilla/embedding/PPrintProgressDialogChild.h"
#include "nsIPrintProgressParams.h"
#include "nsIPrintSettings.h"
#include "nsIWebProgressListener.h"
class nsIObserver;
namespace mozilla {
namespace embedding {
class PrintProgressDialogChild final : public PPrintProgressDialogChild,
public nsIWebProgressListener,
public nsIPrintProgressParams {
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_NSIPRINTPROGRESSPARAMS
public:
MOZ_IMPLICIT PrintProgressDialogChild(nsIObserver* aOpenObserver,
nsIPrintSettings* aPrintSettings);
virtual mozilla::ipc::IPCResult RecvDialogOpened() override;
virtual mozilla::ipc::IPCResult RecvCancelledCurrentJob() override;
private:
virtual ~PrintProgressDialogChild();
nsCOMPtr<nsIObserver> mOpenObserver;
nsString mDocTitle;
nsString mDocURL;
nsCOMPtr<nsIPrintSettings> mPrintSettings;
};
} // namespace embedding
} // namespace mozilla
#endif

View File

@ -1,111 +0,0 @@
/* 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 "mozilla/Unused.h"
#include "nsIWebProgressListener.h"
#include "PrintProgressDialogParent.h"
using mozilla::Unused;
namespace mozilla {
namespace embedding {
NS_IMPL_ISUPPORTS(PrintProgressDialogParent, nsIObserver)
PrintProgressDialogParent::PrintProgressDialogParent() : mActive(true) {}
PrintProgressDialogParent::~PrintProgressDialogParent() = default;
void PrintProgressDialogParent::SetWebProgressListener(
nsIWebProgressListener* aListener) {
mWebProgressListener = aListener;
}
void PrintProgressDialogParent::SetPrintProgressParams(
nsIPrintProgressParams* aParams) {
mPrintProgressParams = aParams;
}
mozilla::ipc::IPCResult PrintProgressDialogParent::RecvStateChange(
const long& stateFlags, const nsresult& status) {
if (mWebProgressListener) {
mWebProgressListener->OnStateChange(nullptr, nullptr, stateFlags, status);
}
return IPC_OK();
}
mozilla::ipc::IPCResult PrintProgressDialogParent::RecvProgressChange(
const long& curSelfProgress, const long& maxSelfProgress,
const long& curTotalProgress, const long& maxTotalProgress) {
if (mWebProgressListener) {
mWebProgressListener->OnProgressChange(nullptr, nullptr, curSelfProgress,
maxSelfProgress, curTotalProgress,
maxTotalProgress);
}
return IPC_OK();
}
mozilla::ipc::IPCResult PrintProgressDialogParent::RecvDocTitleChange(
const nsString& newTitle) {
if (mPrintProgressParams) {
mPrintProgressParams->SetDocTitle(newTitle);
}
return IPC_OK();
}
mozilla::ipc::IPCResult PrintProgressDialogParent::RecvDocURLChange(
const nsString& newURL) {
if (mPrintProgressParams) {
mPrintProgressParams->SetDocURL(newURL);
}
return IPC_OK();
}
void PrintProgressDialogParent::ActorDestroy(ActorDestroyReason aWhy) {
// If IPC actor is destroyed, we can't send to child via IPC.
mActive = false;
}
mozilla::ipc::IPCResult PrintProgressDialogParent::Recv__delete__() {
// The child has requested that we tear down the connection, so we set a
// member to make sure we don't try to contact it after the fact.
mActive = false;
return IPC_OK();
}
// nsIObserver
NS_IMETHODIMP
PrintProgressDialogParent::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
if (mActive) {
if (aTopic) {
if (!strcmp(aTopic, "cancelled")) {
Unused << SendCancelledCurrentJob();
if (!mDialogOpenedSent) {
// We haven't already called SendDialogOpened, so call it now or it
// might never get sent and block the child from new printing
// requests. Also set mActive to false because we don't want to send
// it twice and our PrintProgressDialogChild will get deleted anyway.
Unused << SendDialogOpened();
mActive = false;
}
} else if (!strcmp(aTopic, "completed")) {
// Once printing is complete don't send any messages to the child.
mActive = false;
}
} else {
Unused << SendDialogOpened();
mDialogOpenedSent = true;
}
} else {
NS_WARNING(
"The print progress dialog finished opening, but communications "
"with the child have been closed.");
}
return NS_OK;
}
} // namespace embedding
} // namespace mozilla

View File

@ -1,57 +0,0 @@
/* 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/. */
#ifndef mozilla_embedding_PrintProgressDialogParent_h
#define mozilla_embedding_PrintProgressDialogParent_h
#include "mozilla/embedding/PPrintProgressDialogParent.h"
#include "nsIObserver.h"
class nsIPrintProgressParams;
class nsIWebProgressListener;
namespace mozilla {
namespace embedding {
class PrintProgressDialogParent final : public PPrintProgressDialogParent,
public nsIObserver {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
MOZ_IMPLICIT PrintProgressDialogParent();
void SetWebProgressListener(nsIWebProgressListener* aListener);
void SetPrintProgressParams(nsIPrintProgressParams* aParams);
virtual mozilla::ipc::IPCResult RecvStateChange(
const long& stateFlags, const nsresult& status) override;
virtual mozilla::ipc::IPCResult RecvProgressChange(
const long& curSelfProgress, const long& maxSelfProgress,
const long& curTotalProgress, const long& maxTotalProgress) override;
virtual mozilla::ipc::IPCResult RecvDocTitleChange(
const nsString& newTitle) override;
virtual mozilla::ipc::IPCResult RecvDocURLChange(
const nsString& newURL) override;
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
virtual mozilla::ipc::IPCResult Recv__delete__() override;
private:
virtual ~PrintProgressDialogParent();
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
nsCOMPtr<nsIPrintProgressParams> mPrintProgressParams;
bool mActive;
bool mDialogOpenedSent = false;
};
} // namespace embedding
} // namespace mozilla
#endif

View File

@ -13,9 +13,7 @@
#include "nsIPrintingPromptService.h"
#include "nsIPrintSettingsService.h"
#include "nsServiceManagerUtils.h"
#include "nsIWebProgressListener.h"
#include "PrintingParent.h"
#include "PrintProgressDialogParent.h"
#include "PrintSettingsDialogParent.h"
#include "mozilla/layout/RemotePrintJobParent.h"
#include "mozilla/StaticPrefs_print.h"
@ -26,60 +24,6 @@ using namespace mozilla::layout;
namespace mozilla {
namespace embedding {
mozilla::ipc::IPCResult PrintingParent::RecvShowProgress(
PBrowserParent* parent, PPrintProgressDialogParent* printProgressDialog,
PRemotePrintJobParent* remotePrintJob, const bool& isForPrinting) {
bool notifyOnOpen = false;
nsCOMPtr<nsPIDOMWindowOuter> parentWin = DOMWindowFromBrowserParent(parent);
nsCOMPtr<nsIPrintingPromptService> pps(
do_GetService("@mozilla.org/embedcomp/printingprompt-service;1"));
PrintProgressDialogParent* dialogParent =
static_cast<PrintProgressDialogParent*>(printProgressDialog);
nsCOMPtr<nsIObserver> observer = dialogParent;
nsCOMPtr<nsIWebProgressListener> printProgressListener;
nsCOMPtr<nsIPrintProgressParams> printProgressParams;
nsresult rv = NS_ERROR_INVALID_ARG;
if (parentWin && pps) {
rv = pps->ShowPrintProgressDialog(
parentWin, nullptr, observer, isForPrinting,
getter_AddRefs(printProgressListener),
getter_AddRefs(printProgressParams), &notifyOnOpen);
}
if (NS_SUCCEEDED(rv)) {
if (remotePrintJob) {
// If we have a RemotePrintJob use that as a more general forwarder for
// print progress listeners.
static_cast<RemotePrintJobParent*>(remotePrintJob)
->RegisterListener(printProgressListener);
} else {
dialogParent->SetWebProgressListener(printProgressListener);
}
dialogParent->SetPrintProgressParams(printProgressParams);
}
// NOTE: If we aren't going to observe an event on our observer, we need to
// fake one. This takes the form of sending the SendDialogOpened message. This
// is safe because the child process proxy will always return `true` for
// notifyOnOpen, as the request will always be async when performed across
// process boundaries.
//
// We can pass nullptr for all of the arguments, as all consumers of this
// observer don't care about the subject, topic, or data.
//
// If notifyOnOpen is true, then the ShowProgress call will handle notifying
// our observer for us.
if (!notifyOnOpen) {
observer->Observe(nullptr, nullptr, nullptr);
}
return IPC_OK();
}
nsresult PrintingParent::ShowPrintDialog(PBrowserParent* aParent,
const PrintData& aData,
PrintData* aResult) {
@ -200,24 +144,6 @@ mozilla::ipc::IPCResult PrintingParent::RecvSavePrintSettings(
return IPC_OK();
}
PPrintProgressDialogParent* PrintingParent::AllocPPrintProgressDialogParent() {
PrintProgressDialogParent* actor = new PrintProgressDialogParent();
NS_ADDREF(actor); // De-ref'd in the __delete__ handler for
// PrintProgressDialogParent.
return actor;
}
bool PrintingParent::DeallocPPrintProgressDialogParent(
PPrintProgressDialogParent* doomed) {
// We can't just delete the PrintProgressDialogParent since somebody might
// still be holding a reference to it as nsIObserver, so just decrement the
// refcount instead.
PrintProgressDialogParent* actor =
static_cast<PrintProgressDialogParent*>(doomed);
NS_RELEASE(actor);
return true;
}
PPrintSettingsDialogParent* PrintingParent::AllocPPrintSettingsDialogParent() {
return new PrintSettingsDialogParent();
}

View File

@ -13,7 +13,6 @@
class nsIPrintSettingsService;
class nsIWebProgressListener;
class nsPIDOMWindowOuter;
class PPrintProgressDialogParent;
class PPrintSettingsDialogParent;
namespace mozilla {
@ -28,9 +27,6 @@ class PrintingParent final : public PPrintingParent {
public:
NS_INLINE_DECL_REFCOUNTING(PrintingParent)
mozilla::ipc::IPCResult RecvShowProgress(
PBrowserParent* parent, PPrintProgressDialogParent* printProgressDialog,
PRemotePrintJobParent* remotePrintJob, const bool& isForPrinting) final;
mozilla::ipc::IPCResult RecvShowPrintDialog(
PPrintSettingsDialogParent* aDialog, PBrowserParent* aParent,
const PrintData& aData) final;
@ -39,11 +35,6 @@ class PrintingParent final : public PPrintingParent {
const PrintData& data, const bool& usePrinterNamePrefix,
const uint32_t& flags, nsresult* rv) final;
PPrintProgressDialogParent* AllocPPrintProgressDialogParent() final;
bool DeallocPPrintProgressDialogParent(
PPrintProgressDialogParent* aActor) final;
PPrintSettingsDialogParent* AllocPPrintSettingsDialogParent() final;
bool DeallocPPrintSettingsDialogParent(

View File

@ -16,8 +16,6 @@ if CONFIG["NS_PRINTING"]:
UNIFIED_SOURCES += [
"nsPrintingProxy.cpp",
"PrintingParent.cpp",
"PrintProgressDialogChild.cpp",
"PrintProgressDialogParent.cpp",
"PrintSettingsDialogChild.cpp",
"PrintSettingsDialogParent.cpp",
]
@ -25,7 +23,6 @@ if CONFIG["NS_PRINTING"]:
IPDL_SOURCES += [
"PPrinting.ipdl",
"PPrintingTypes.ipdlh",
"PPrintProgressDialog.ipdl",
"PPrintSettingsDialog.ipdl",
]

View File

@ -18,7 +18,6 @@
#include "nsPIDOMWindow.h"
#include "nsPrintSettingsService.h"
#include "nsServiceManagerUtils.h"
#include "PrintProgressDialogChild.h"
#include "PrintSettingsDialogChild.h"
using namespace mozilla;
@ -118,60 +117,6 @@ nsPrintingProxy::ShowPrintDialog(mozIDOMWindowProxy* parent,
return NS_OK;
}
NS_IMETHODIMP
nsPrintingProxy::ShowPrintProgressDialog(
mozIDOMWindowProxy* parent,
nsIPrintSettings* printSettings, // ok to be null
nsIObserver* openDialogObserver, // ok to be null
bool isForPrinting, nsIWebProgressListener** webProgressListener,
nsIPrintProgressParams** printProgressParams, bool* notifyOnOpen) {
NS_ENSURE_ARG(parent);
NS_ENSURE_ARG(webProgressListener);
NS_ENSURE_ARG(printProgressParams);
NS_ENSURE_ARG(notifyOnOpen);
// Get the BrowserChild for this nsIDOMWindow, which we can then pass up to
// the parent.
nsCOMPtr<nsPIDOMWindowOuter> pwin = nsPIDOMWindowOuter::From(parent);
NS_ENSURE_STATE(pwin);
nsCOMPtr<nsIDocShell> docShell = pwin->GetDocShell();
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIBrowserChild> tabchild = docShell->GetBrowserChild();
BrowserChild* pBrowser = static_cast<BrowserChild*>(tabchild.get());
RefPtr<PrintProgressDialogChild> dialogChild =
new PrintProgressDialogChild(openDialogObserver, printSettings);
SendPPrintProgressDialogConstructor(dialogChild);
// Get the RemotePrintJob if we have one available.
RefPtr<RemotePrintJobChild> remotePrintJob;
if (printSettings) {
nsCOMPtr<nsIPrintSession> printSession;
nsresult rv = printSettings->GetPrintSession(getter_AddRefs(printSession));
if (NS_SUCCEEDED(rv) && printSession) {
remotePrintJob = printSession->GetRemotePrintJob();
}
}
// NOTE: We set notifyOnOpen to true unconditionally. If the parent process
// would get `false` for notifyOnOpen, then it will synthesize a notification
// which will be sent asynchronously down to the child.
*notifyOnOpen = true;
mozilla::Unused << SendShowProgress(pBrowser, dialogChild, remotePrintJob,
isForPrinting);
// If we have a RemotePrintJob that will be being used as a more general
// forwarder for print progress listeners. Once we always have one we can
// remove the interface from PrintProgressDialogChild.
if (!remotePrintJob) {
NS_ADDREF(*webProgressListener = dialogChild);
}
NS_ADDREF(*printProgressParams = dialogChild);
return NS_OK;
}
NS_IMETHODIMP
nsPrintingProxy::ShowPageSetupDialog(mozIDOMWindowProxy* parent,
nsIPrintSettings* printSettings) {
@ -194,22 +139,6 @@ nsresult nsPrintingProxy::SavePrintSettings(nsIPrintSettings* aPS,
return rv;
}
PPrintProgressDialogChild* nsPrintingProxy::AllocPPrintProgressDialogChild() {
// The parent process will never initiate the PPrintProgressDialog
// protocol connection, so no need to provide an allocator here.
MOZ_ASSERT_UNREACHABLE(
"Allocator for PPrintProgressDialogChild should not "
"be called on nsPrintingProxy.");
return nullptr;
}
bool nsPrintingProxy::DeallocPPrintProgressDialogChild(
PPrintProgressDialogChild* aActor) {
// The PrintProgressDialogChild implements refcounting, and
// will take itself out.
return true;
}
PPrintSettingsDialogChild* nsPrintingProxy::AllocPPrintSettingsDialogChild() {
// The parent process will never initiate the PPrintSettingsDialog
// protocol connection, so no need to provide an allocator here.

View File

@ -36,11 +36,6 @@ class nsPrintingProxy final : public nsIPrintingPromptService,
uint32_t aFlags);
protected:
PPrintProgressDialogChild* AllocPPrintProgressDialogChild() final;
bool DeallocPPrintProgressDialogChild(
PPrintProgressDialogChild* aActor) final;
PPrintSettingsDialogChild* AllocPPrintSettingsDialogChild() final;
bool DeallocPPrintSettingsDialogChild(

View File

@ -13,10 +13,5 @@ if CONFIG["NS_PRINTING"]:
UNIFIED_SOURCES += [
"nsPrintingPromptService.cpp",
]
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "windows" or CONFIG["MOZ_PDF_PRINTING"]:
UNIFIED_SOURCES += [
"nsPrintProgress.cpp",
"nsPrintProgressParams.cpp",
]
FINAL_LIBRARY = "xul"

View File

@ -1,265 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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 "nsPrintProgress.h"
#include "mozilla/dom/BrowsingContext.h"
#include "nsArray.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIPrintSettings.h"
#include "nsIAppWindow.h"
#include "nsXPCOM.h"
#include "nsIObserver.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsPIDOMWindow.h"
#include "nsXULAppAPI.h"
using mozilla::dom::BrowsingContext;
NS_IMPL_ADDREF(nsPrintProgress)
NS_IMPL_RELEASE(nsPrintProgress)
NS_INTERFACE_MAP_BEGIN(nsPrintProgress)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIPrintProgress)
NS_INTERFACE_MAP_ENTRY(nsIPrintProgress)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_END
nsPrintProgress::nsPrintProgress(nsIPrintSettings* aPrintSettings) {
m_closeProgress = false;
m_processCanceled = false;
m_pendingStateFlags = -1;
m_pendingStateValue = NS_OK;
m_PrintSetting = aPrintSettings;
}
nsPrintProgress::~nsPrintProgress() { (void)ReleaseListeners(); }
NS_IMETHODIMP nsPrintProgress::OpenProgressDialog(
mozIDOMWindowProxy* parent, const char* dialogURL, nsISupports* parameters,
nsIObserver* openDialogObserver, bool* notifyOnOpen) {
*notifyOnOpen = true;
m_observer = openDialogObserver;
nsresult rv = NS_ERROR_FAILURE;
if (m_dialog) return NS_ERROR_ALREADY_INITIALIZED;
if (!dialogURL || !*dialogURL) return NS_ERROR_INVALID_ARG;
if (parent) {
// Set up window.arguments[0]...
nsCOMPtr<nsIMutableArray> array = nsArray::Create();
nsCOMPtr<nsISupportsInterfacePointer> ifptr =
do_CreateInstance(NS_SUPPORTS_INTERFACE_POINTER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
ifptr->SetData(static_cast<nsIPrintProgress*>(this));
ifptr->SetDataIID(&NS_GET_IID(nsIPrintProgress));
array->AppendElement(ifptr);
array->AppendElement(parameters);
// We will set the opener of the dialog to be the nsIDOMWindow for the
// browser XUL window itself, as opposed to the content. That way, the
// progress window has access to the opener.
nsCOMPtr<nsPIDOMWindowOuter> pParentWindow =
nsPIDOMWindowOuter::From(parent);
NS_ENSURE_STATE(pParentWindow);
nsCOMPtr<nsIDocShell> docShell = pParentWindow->GetDocShell();
NS_ENSURE_STATE(docShell);
nsCOMPtr<nsIDocShellTreeOwner> owner;
docShell->GetTreeOwner(getter_AddRefs(owner));
nsCOMPtr<nsIAppWindow> ownerAppWindow = do_GetInterface(owner);
nsCOMPtr<mozIDOMWindowProxy> ownerWindow = do_GetInterface(ownerAppWindow);
NS_ENSURE_STATE(ownerWindow);
nsCOMPtr<nsPIDOMWindowOuter> piOwnerWindow =
nsPIDOMWindowOuter::From(ownerWindow);
// Open the dialog.
RefPtr<BrowsingContext> newBC;
rv = piOwnerWindow->OpenDialog(NS_ConvertASCIItoUTF16(dialogURL),
u"_blank"_ns,
u"chrome,titlebar,dependent,centerscreen"_ns,
array, getter_AddRefs(newBC));
}
return rv;
}
NS_IMETHODIMP nsPrintProgress::CloseProgressDialog(bool forceClose) {
m_closeProgress = true;
// XXX Invalid cast of bool to nsresult (bug 778106)
return OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP,
(nsresult)forceClose);
}
NS_IMETHODIMP nsPrintProgress::GetPrompter(nsIPrompt** _retval) {
NS_ENSURE_ARG_POINTER(_retval);
*_retval = nullptr;
if (!m_closeProgress && m_dialog) {
nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryInterface(m_dialog);
MOZ_ASSERT(window);
return window->GetPrompter(_retval);
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsPrintProgress::GetProcessCanceledByUser(
bool* aProcessCanceledByUser) {
NS_ENSURE_ARG_POINTER(aProcessCanceledByUser);
*aProcessCanceledByUser = m_processCanceled;
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::SetProcessCanceledByUser(
bool aProcessCanceledByUser) {
if (XRE_IsE10sParentProcess()) {
MOZ_ASSERT(m_observer);
m_observer->Observe(nullptr, "cancelled", nullptr);
}
if (m_PrintSetting) m_PrintSetting->SetIsCancelled(true);
m_processCanceled = aProcessCanceledByUser;
OnStateChange(nullptr, nullptr, nsIWebProgressListener::STATE_STOP, NS_OK);
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::RegisterListener(
nsIWebProgressListener* listener) {
if (!listener) // Nothing to do with a null listener!
return NS_OK;
m_listenerList.AppendObject(listener);
if (m_closeProgress || m_processCanceled)
listener->OnStateChange(nullptr, nullptr,
nsIWebProgressListener::STATE_STOP, NS_OK);
else {
listener->OnStatusChange(nullptr, nullptr, NS_OK, m_pendingStatus.get());
if (m_pendingStateFlags != -1)
listener->OnStateChange(nullptr, nullptr, m_pendingStateFlags,
m_pendingStateValue);
}
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::UnregisterListener(
nsIWebProgressListener* listener) {
if (listener) m_listenerList.RemoveObject(listener);
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::DoneIniting() {
if (m_observer) {
m_observer->Observe(nullptr, nullptr, nullptr);
}
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aStateFlags,
nsresult aStatus) {
if (XRE_IsE10sParentProcess() &&
aStateFlags & nsIWebProgressListener::STATE_STOP) {
// If we're in an e10s parent, m_observer is a PrintProgressDialogParent,
// so we let it know that printing has completed, because it might mean that
// its PrintProgressDialogChild has already been deleted.
m_observer->Observe(nullptr, "completed", nullptr);
}
m_pendingStateFlags = aStateFlags;
m_pendingStateValue = aStatus;
uint32_t count = m_listenerList.Count();
for (uint32_t i = count - 1; i < count; i--) {
nsCOMPtr<nsIWebProgressListener> progressListener =
m_listenerList.SafeObjectAt(i);
if (progressListener)
progressListener->OnStateChange(aWebProgress, aRequest, aStateFlags,
aStatus);
}
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::OnProgressChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
int32_t aCurSelfProgress,
int32_t aMaxSelfProgress,
int32_t aCurTotalProgress,
int32_t aMaxTotalProgress) {
if (XRE_IsE10sParentProcess() && aCurSelfProgress &&
aCurSelfProgress >= aMaxSelfProgress) {
// If we're in an e10s parent, m_observer is a PrintProgressDialogParent,
// so we let it know that printing has completed, because it might mean that
// its PrintProgressDialogChild has already been deleted.
m_observer->Observe(nullptr, "completed", nullptr);
}
uint32_t count = m_listenerList.Count();
for (uint32_t i = count - 1; i < count; i--) {
nsCOMPtr<nsIWebProgressListener> progressListener =
m_listenerList.SafeObjectAt(i);
if (progressListener)
progressListener->OnProgressChange(aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* location,
uint32_t aFlags) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsPrintProgress::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsresult aStatus,
const char16_t* aMessage) {
if (aMessage && *aMessage) m_pendingStatus = aMessage;
uint32_t count = m_listenerList.Count();
for (uint32_t i = count - 1; i < count; i--) {
nsCOMPtr<nsIWebProgressListener> progressListener =
m_listenerList.SafeObjectAt(i);
if (progressListener)
progressListener->OnStatusChange(aWebProgress, aRequest, aStatus,
aMessage);
}
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::OnSecurityChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aState) {
return NS_OK;
}
NS_IMETHODIMP nsPrintProgress::OnContentBlockingEvent(
nsIWebProgress* aWebProgress, nsIRequest* aRequest, uint32_t aEvent) {
return NS_OK;
}
nsresult nsPrintProgress::ReleaseListeners() {
m_listenerList.Clear();
return NS_OK;
}

View File

@ -1,44 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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/. */
#ifndef __nsPrintProgress_h
#define __nsPrintProgress_h
#include "nsIPrintProgress.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "nsString.h"
class nsIDOMWindow;
class nsIObserver;
class nsIPrintSettings;
class nsPrintProgress : public nsIPrintProgress {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIPRINTPROGRESS
NS_DECL_NSIWEBPROGRESSLISTENER
explicit nsPrintProgress(nsIPrintSettings* aPrintSettings);
protected:
virtual ~nsPrintProgress();
private:
nsresult ReleaseListeners();
bool m_closeProgress;
bool m_processCanceled;
nsString m_pendingStatus;
int32_t m_pendingStateFlags;
nsresult m_pendingStateValue;
nsCOMPtr<nsIDOMWindow> m_dialog;
nsCOMArray<nsIWebProgressListener> m_listenerList;
nsCOMPtr<nsIObserver> m_observer;
nsCOMPtr<nsIPrintSettings> m_PrintSetting;
};
#endif

View File

@ -1,37 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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 "nsPrintProgressParams.h"
#include "nsReadableUtils.h"
NS_IMPL_ISUPPORTS(nsPrintProgressParams, nsIPrintProgressParams)
nsPrintProgressParams::nsPrintProgressParams() = default;
nsPrintProgressParams::~nsPrintProgressParams() = default;
NS_IMETHODIMP
nsPrintProgressParams::GetDocTitle(nsAString& aDocTitle) {
aDocTitle = mDocTitle;
return NS_OK;
}
NS_IMETHODIMP
nsPrintProgressParams::SetDocTitle(const nsAString& aDocTitle) {
mDocTitle = aDocTitle;
return NS_OK;
}
NS_IMETHODIMP
nsPrintProgressParams::GetDocURL(nsAString& aDocURL) {
aDocURL = mDocURL;
return NS_OK;
}
NS_IMETHODIMP
nsPrintProgressParams::SetDocURL(const nsAString& aDocURL) {
mDocURL = aDocURL;
return NS_OK;
}

View File

@ -1,27 +0,0 @@
/* -*- Mode: C++; tab-width: 2; 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/. */
#ifndef __nsPrintProgressParams_h
#define __nsPrintProgressParams_h
#include "nsIPrintProgressParams.h"
#include "nsString.h"
class nsPrintProgressParams : public nsIPrintProgressParams {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTPROGRESSPARAMS
nsPrintProgressParams();
protected:
virtual ~nsPrintProgressParams();
private:
nsString mDocTitle;
nsString mDocURL;
};
#endif

View File

@ -15,21 +15,9 @@
#include "nsServiceManagerUtils.h"
#include "nsXULAppAPI.h"
// Printing Progress Includes
#if !defined(XP_MACOSX)
# include "nsPrintProgress.h"
# include "nsPrintProgressParams.h"
static const char* kPrintProgressDialogURL =
"chrome://global/content/printProgress.xhtml";
static const char* kPrtPrvProgressDialogURL =
"chrome://global/content/printPreviewProgress.xhtml";
#endif
using namespace mozilla;
NS_IMPL_ISUPPORTS(nsPrintingPromptService, nsIPrintingPromptService,
nsIWebProgressListener)
NS_IMPL_ISUPPORTS(nsPrintingPromptService, nsIPrintingPromptService)
StaticRefPtr<nsPrintingPromptService> sSingleton;
@ -75,54 +63,6 @@ nsPrintingPromptService::ShowPrintDialog(mozIDOMWindowProxy* parent,
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsPrintingPromptService::ShowPrintProgressDialog(
mozIDOMWindowProxy* parent,
nsIPrintSettings* printSettings, // ok to be null
nsIObserver* openDialogObserver, // ok to be null
bool isForPrinting, nsIWebProgressListener** webProgressListener,
nsIPrintProgressParams** printProgressParams, bool* notifyOnOpen) {
#if !defined(XP_MACOSX)
NS_ENSURE_ARG(webProgressListener);
NS_ENSURE_ARG(printProgressParams);
NS_ENSURE_ARG(notifyOnOpen);
*notifyOnOpen = false;
if (mPrintProgress) {
*webProgressListener = nullptr;
*printProgressParams = nullptr;
return NS_ERROR_FAILURE;
}
nsPrintProgress* prtProgress = new nsPrintProgress(printSettings);
mPrintProgress = prtProgress;
mWebProgressListener = prtProgress;
nsCOMPtr<nsIPrintProgressParams> prtProgressParams =
new nsPrintProgressParams();
nsCOMPtr<mozIDOMWindowProxy> parentWindow = parent;
if (mWatcher && !parentWindow) {
mWatcher->GetActiveWindow(getter_AddRefs(parentWindow));
}
if (parentWindow) {
mPrintProgress->OpenProgressDialog(
parentWindow,
isForPrinting ? kPrintProgressDialogURL : kPrtPrvProgressDialogURL,
prtProgressParams, openDialogObserver, notifyOnOpen);
}
prtProgressParams.forget(printProgressParams);
NS_ADDREF(*webProgressListener = this);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
NS_IMETHODIMP
nsPrintingPromptService::ShowPageSetupDialog(mozIDOMWindowProxy* parent,
nsIPrintSettings* printSettings) {
@ -136,90 +76,3 @@ nsPrintingPromptService::ShowPageSetupDialog(mozIDOMWindowProxy* parent,
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsPrintingPromptService::OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aStateFlags, nsresult aStatus) {
#if !defined(XP_MACOSX)
if ((aStateFlags & STATE_STOP) && mWebProgressListener) {
mWebProgressListener->OnStateChange(aWebProgress, aRequest, aStateFlags,
aStatus);
if (mPrintProgress) {
mPrintProgress->CloseProgressDialog(true);
}
mPrintProgress = nullptr;
mWebProgressListener = nullptr;
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptService::OnProgressChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
int32_t aCurSelfProgress,
int32_t aMaxSelfProgress,
int32_t aCurTotalProgress,
int32_t aMaxTotalProgress) {
#if !defined(XP_MACOSX)
if (mWebProgressListener) {
return mWebProgressListener->OnProgressChange(
aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptService::OnLocationChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
nsIURI* location, uint32_t aFlags) {
#if !defined(XP_MACOSX)
if (mWebProgressListener) {
return mWebProgressListener->OnLocationChange(aWebProgress, aRequest,
location, aFlags);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptService::OnStatusChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest, nsresult aStatus,
const char16_t* aMessage) {
#if !defined(XP_MACOSX)
if (mWebProgressListener) {
return mWebProgressListener->OnStatusChange(aWebProgress, aRequest, aStatus,
aMessage);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptService::OnSecurityChange(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aState) {
#if !defined(XP_MACOSX)
if (mWebProgressListener) {
return mWebProgressListener->OnSecurityChange(aWebProgress, aRequest,
aState);
}
#endif
return NS_OK;
}
NS_IMETHODIMP
nsPrintingPromptService::OnContentBlockingEvent(nsIWebProgress* aWebProgress,
nsIRequest* aRequest,
uint32_t aEvent) {
#if !defined(XP_MACOSX)
if (mWebProgressListener) {
return mWebProgressListener->OnContentBlockingEvent(aWebProgress, aRequest,
aEvent);
}
#endif
return NS_OK;
}

View File

@ -20,22 +20,16 @@
#include "nsIPrintingPromptService.h"
#include "nsIWindowWatcher.h"
// Printing Progress Includes
#include "nsIWebProgressListener.h"
#if !defined(XP_MACOSX)
# include "nsPrintProgress.h"
class nsIDOMWindow;
class nsIDialogParamBlock;
#endif
class nsPrintingPromptService final : public nsIPrintingPromptService,
public nsIWebProgressListener {
class nsPrintingPromptService final : public nsIPrintingPromptService {
public:
static already_AddRefed<nsPrintingPromptService> GetSingleton();
NS_DECL_NSIPRINTINGPROMPTSERVICE
NS_DECL_NSIWEBPROGRESSLISTENER
NS_DECL_ISUPPORTS
protected:
@ -46,8 +40,6 @@ class nsPrintingPromptService final : public nsIPrintingPromptService,
private:
#if !defined(XP_MACOSX)
nsCOMPtr<nsIWindowWatcher> mWatcher;
nsCOMPtr<nsIPrintProgress> mPrintProgress;
nsCOMPtr<nsIWebProgressListener> mWebProgressListener;
#endif
};

View File

@ -279,7 +279,6 @@ interface nsIPrintSettings : nsISupports
readonly attribute boolean saveOnCancel; /* indicates whether the print settings should be saved after a cancel */
attribute boolean printSilent; /* print without putting up the dialog */
[infallible] attribute boolean shrinkToFit; /* shrinks content to fit on page */
attribute boolean showPrintProgress; /* indicates whether the progress dialog should be shown */
/* Additional XP Related */
attribute AString paperId; /* identifier of paper (not display name) */

View File

@ -28,7 +28,6 @@ nsPrintSettings::nsPrintSettings()
mSaveOnCancel(true),
mPrintSilent(false),
mShrinkToFit(true),
mShowPrintProgress(true),
mShowMarginGuides(false),
mHonorPageRuleMargins(true),
mIsPrintSelectionRBEnabled(false),
@ -542,16 +541,6 @@ NS_IMETHODIMP nsPrintSettings::SetShrinkToFit(bool aShrinkToFit) {
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetShowPrintProgress(bool* aShowPrintProgress) {
NS_ENSURE_ARG_POINTER(aShowPrintProgress);
*aShowPrintProgress = mShowPrintProgress;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::SetShowPrintProgress(bool aShowPrintProgress) {
mShowPrintProgress = aShowPrintProgress;
return NS_OK;
}
NS_IMETHODIMP nsPrintSettings::GetShowMarginGuides(bool* aShowMarginGuides) {
*aShowMarginGuides = mShowMarginGuides;
return NS_OK;
@ -947,7 +936,6 @@ nsPrintSettings& nsPrintSettings::operator=(const nsPrintSettings& rhs) {
mSaveOnCancel = rhs.mSaveOnCancel;
mPrintSilent = rhs.mPrintSilent;
mShrinkToFit = rhs.mShrinkToFit;
mShowPrintProgress = rhs.mShowPrintProgress;
mShowMarginGuides = rhs.mShowMarginGuides;
mHonorPageRuleMargins = rhs.mHonorPageRuleMargins;
mIsPrintSelectionRBEnabled = rhs.mIsPrintSelectionRBEnabled;

View File

@ -103,7 +103,6 @@ class nsPrintSettings : public nsIPrintSettings {
bool mSaveOnCancel;
bool mPrintSilent;
bool mShrinkToFit;
bool mShowPrintProgress;
bool mShowMarginGuides;
bool mHonorPageRuleMargins;
bool mIsPrintSelectionRBEnabled;

View File

@ -139,7 +139,6 @@ nsPrintSettingsService::SerializeToPrintData(nsIPrintSettings* aSettings,
aSettings->GetIsCancelled(&data->isCancelled());
aSettings->GetPrintSilent(&data->printSilent());
aSettings->GetShrinkToFit(&data->shrinkToFit());
aSettings->GetShowPrintProgress(&data->showPrintProgress());
aSettings->GetPaperId(data->paperId());
aSettings->GetPaperWidth(&data->paperWidth());
@ -228,7 +227,6 @@ nsPrintSettingsService::DeserializeToPrintSettings(const PrintData& data,
settings->SetIsCancelled(data.isCancelled());
settings->SetPrintSilent(data.printSilent());
settings->SetShrinkToFit(data.shrinkToFit());
settings->SetShowPrintProgress(data.showPrintProgress());
settings->SetPaperId(data.paperId());