Bug 1409972 - Part 3. Merge windows printingui. r=mconley
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 10 Nov 2017 10:58:10 +0900
changeset 391645 fb5f9d6a7772fd99f362a8a9d50d03af849d508f
parent 391644 96fcac56b31e950d74aa189f52a233a27b8ec903
child 391646 1d8e9cd8df19cc4e6decc12aee007f559ed2cbbf
push id55288
push usermantaroh@gmail.com
push dateTue, 14 Nov 2017 01:30:51 +0000
treeherderautoland@854a8759f855 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1409972, 156318
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
     // 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();
     nsCOMPtr<nsIDocShellTreeOwner> 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)
   *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();