Bug 1409972 - Part 3. Merge windows printingui. r?mconley
This patch will merge windows printingui implementation to common code.
Primary differences are:
* Use nsCOMPtr on nsPIDOMWindowOuter.
* Return NS_ERROR_FAILURE if nsPrintingPromptService doesn't have the
nsPrintProgress member when calling ShowProgress().
This is the unexpected case.
Original windows implementation has following difference, but this patch will
not copy it:
* Windows has own NS_IMPL_ADDREF / NS_IMPL_RELEASE implementation, however this
implementation isn't different from XPCOM implementation.
Bug 156318
doesn't show this reason.
* Windows implementation lacks some function parameter checks.
But unixshared code covers these checks.
* Windows implementation doesn't have the nsIPrintSettings member into
nsPrintProgress, but this is necessary in order to make printing cancelable.
MozReview-Commit-ID: 8ja40rAaXBo
--- a/toolkit/components/printingui/nsPrintProgress.cpp
+++ b/toolkit/components/printingui/nsPrintProgress.cpp
@@ -72,17 +72,18 @@ NS_IMETHODIMP nsPrintProgress::OpenProgr
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.
- auto* pParentWindow = nsPIDOMWindowOuter::From(parent);
+ 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<nsIXULWindow> ownerXULWindow = do_GetInterface(owner);
nsCOMPtr<mozIDOMWindowProxy> ownerWindow = do_GetInterface(ownerXULWindow);
--- a/toolkit/components/printingui/nsPrintingPromptService.cpp
+++ b/toolkit/components/printingui/nsPrintingPromptService.cpp
@@ -64,16 +64,21 @@ nsPrintingPromptService::ShowProgress(
nsIPrintProgressParams** printProgressParams,
bool* notifyOnOpen)
{
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();