Bug 1552449. Make the nsIDocShell interface to print preview less susceptible to inadvertent misuse. r=bobowen

Differential Revision: https://phabricator.services.mozilla.com/D31598
This commit is contained in:
Jonathan Watt
2019-05-07 14:12:44 +01:00
parent 0dd17f1e99
commit f1c7596e49
7 changed files with 48 additions and 18 deletions

View File

@@ -12916,7 +12916,7 @@ void nsDocShell::SetIsPrinting(bool aIsPrinting) {
}
NS_IMETHODIMP
nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview) {
nsDocShell::InitOrReusePrintPreviewViewer(nsIWebBrowserPrint** aPrintPreview) {
*aPrintPreview = nullptr;
#if NS_PRINT_PREVIEW
nsCOMPtr<nsIDocumentViewerPrint> print = do_QueryInterface(mContentViewer);
@@ -12947,6 +12947,19 @@ nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview) {
#endif
}
NS_IMETHODIMP nsDocShell::ExitPrintPreview() {
#if NS_PRINT_PREVIEW
# ifdef DEBUG
nsCOMPtr<nsIDocumentViewerPrint> vp = do_QueryInterface(mContentViewer);
MOZ_ASSERT(vp && vp->IsInitializedForPrintPreview());
# endif
nsCOMPtr<nsIWebBrowserPrint> viewer = do_QueryInterface(mContentViewer);
return viewer->ExitPrintPreview();
#else
return NS_OK;
#endif
}
#ifdef DEBUG
unsigned long nsDocShell::gNumberOfDocShells = 0;
#endif