Bug 1430619 part 2 - Move nsIContentViewerContainer::setIsPrinting to nsIDocShell. r=freesamael draft
authorJonathan Watt <jwatt@jwatt.org>
Wed, 17 Jan 2018 10:53:23 +0000
changeset 721533 768cb7d0d87bae43d6f134e1d4d4273bb161f996
parent 721532 83d8e1d978ee9755636557b457df2cde9a72f169
child 721534 ebc0f309d2d96fb785941684c1fbe4af6d1dfe8d
push id95856
push userjwatt@jwatt.org
push dateWed, 17 Jan 2018 10:55:16 +0000
reviewersfreesamael
bugs1430619
milestone59.0a1
Bug 1430619 part 2 - Move nsIContentViewerContainer::setIsPrinting to nsIDocShell. r=freesamael MozReview-Commit-ID: HNc5IY9B42V
docshell/base/nsDocShell.cpp
docshell/base/nsIContentViewerContainer.idl
docshell/base/nsIDocShell.idl
layout/base/nsDocumentViewer.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -6914,22 +6914,16 @@ nsDocShell::Embed(nsIContentViewer* aCon
 
   if (!updateHistory) {
     SetLayoutHistoryState(nullptr);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDocShell::SetIsPrinting(bool aIsPrinting)
-{
-  mIsPrintingOrPP = aIsPrinting;
-  return NS_OK;
-}
 
 //*****************************************************************************
 // nsDocShell::nsIWebProgressListener
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsDocShell::OnProgressChange(nsIWebProgress* aProgress,
                              nsIRequest* aRequest,
@@ -13844,16 +13838,23 @@ nsDocShell::StopDocumentLoad(void)
     Stop(nsIWebNavigation::STOP_ALL);
     return NS_OK;
   }
   // return failer if this request is not accepted due to mCharsetReloadState
   return NS_ERROR_DOCSHELL_REQUEST_REJECTED;
 }
 
 NS_IMETHODIMP
+nsDocShell::SetIsPrinting(bool aIsPrinting)
+{
+  mIsPrintingOrPP = aIsPrinting;
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview)
 {
   *aPrintPreview = nullptr;
 #if NS_PRINT_PREVIEW
   nsCOMPtr<nsIDocumentViewerPrint> print = do_QueryInterface(mContentViewer);
   if (!print || !print->IsInitializedForPrintPreview()) {
     // XXX: Creating a brand new content viewer to host preview every
     // time we enter here seems overwork. We could skip ahead to where
--- a/docshell/base/nsIContentViewerContainer.idl
+++ b/docshell/base/nsIContentViewerContainer.idl
@@ -5,14 +5,9 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
 interface nsIContentViewer;
 
 [scriptable, uuid(ea2ce7a0-5c3d-11d4-90c2-0050041caf44)]
 interface nsIContentViewerContainer : nsISupports {
-  /**
-   * Allows nsPrintJob to make this call on an internal interface to the
-   * DocShell.
-   */
-  void setIsPrinting(in boolean aIsPrinting);
 };
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -651,16 +651,22 @@ interface nsIDocShell : nsIDocShellTreeI
   /**
    * If true, this browser is not visible in the traditional sense, but
    * is actively being rendered to the screen (ex. painted on a canvas)
    * and should be treated accordingly.
    **/
   attribute boolean isOffScreenBrowser;
 
   /**
+   * Allows nsDocumentViewer to tell the top-level same-type docshell that
+   * one of the documents under it is printing.
+   */
+  void setIsPrinting(in boolean aIsPrinting);
+
+  /**
    * If the current content viewer isn't initialized for print preview,
    * it is replaced with one which is and to which an about:blank document
    * is loaded.
    */
   readonly attribute nsIWebBrowserPrint printPreview;
 
   /**
    * Whether this docshell can execute scripts based on its hierarchy.
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/ServoStyleSet.h"
 #include "nsAutoPtr.h"
 #include "nscore.h"
 #include "nsCOMPtr.h"
 #include "nsCRT.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
 #include "nsIContent.h"
-#include "nsIContentViewerContainer.h"
 #include "nsIContentViewer.h"
 #include "nsIDocumentViewerPrint.h"
 #include "mozilla/dom/BeforeUnloadEvent.h"
 #include "nsIDocument.h"
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "mozilla/StyleSetHandle.h"
 #include "mozilla/StyleSetHandleInlines.h"
@@ -4322,17 +4321,17 @@ nsDocumentViewer::SetIsPrintingInDocShel
       }
       mTopContainerWhilePrinting = do_GetWeakReference(parentItem);
     } else {
       parentItem = do_QueryReferent(mTopContainerWhilePrinting);
     }
   }
 
   // Check to see if the DocShell's ContentViewer is printing/PP
-  nsCOMPtr<nsIContentViewerContainer> viewerContainer(do_QueryInterface(parentItem));
+  nsCOMPtr<nsIDocShell> viewerContainer = do_QueryInterface(parentItem);
   if (viewerContainer) {
     viewerContainer->SetIsPrinting(aIsPrintingOrPP);
   }
 
   if (!aParentNode) {
     return;
   }