Bug 1409972 - Part 3. Merge windows printingui. r?mconley draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 10 Nov 2017 10:58:10 +0900
changeset 695955 3e8c2888e0bc606be2ccc8fe3a1fff93d2c5e6d7
parent 695954 7309c9dc64f570d494eaaa289592674e93708d83
child 695956 617649c5a48309ff213c80bc74318276f18acadc
push id88595
push usermantaroh@gmail.com
push dateFri, 10 Nov 2017 02:11:26 +0000
reviewersmconley
bugs1409972, 156318
milestone58.0a1
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
toolkit/components/printingui/nsPrintProgress.cpp
toolkit/components/printingui/nsPrintingPromptService.cpp
--- 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();