Bug 487667 - Clone documents for printing, r=roc+jst+joe+dbaron

This commit is contained in:
Olli Pettay
2009-12-10 20:02:13 -08:00
parent be28d4906a
commit 2e3d0c93fe
73 changed files with 1422 additions and 495 deletions

View File

@@ -202,6 +202,11 @@
// for embedding
#include "nsIWebBrowserChromeFocus.h"
#if NS_PRINT_PREVIEW
#include "nsIDocumentViewerPrint.h"
#include "nsIWebBrowserPrint.h"
#endif
#include "nsPluginError.h"
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
@@ -11072,6 +11077,32 @@ nsDocShell::SetRendering(PRBool aRender)
return NS_ERROR_DOCSHELL_REQUEST_REJECTED;
}
NS_IMETHODIMP
nsDocShell::GetPrintPreview(nsIWebBrowserPrint** aPrintPreview)
{
*aPrintPreview = nsnull;
#if NS_PRINT_PREVIEW
nsCOMPtr<nsIDocumentViewerPrint> print = do_QueryInterface(mContentViewer);
if (!print || !print->IsInitializedForPrintPreview()) {
Stop(nsIWebNavigation::STOP_ALL);
nsCOMPtr<nsIPrincipal> principal =
do_CreateInstance("@mozilla.org/nullprincipal;1");
NS_ENSURE_STATE(principal);
nsresult rv = CreateAboutBlankContentViewer(principal, nsnull);
NS_ENSURE_SUCCESS(rv, rv);
print = do_QueryInterface(mContentViewer);
NS_ENSURE_STATE(print);
print->InitializeForPrintPreview();
}
nsCOMPtr<nsIWebBrowserPrint> result = do_QueryInterface(print);
result.forget(aPrintPreview);
return NS_OK;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
}
#ifdef DEBUG
unsigned long nsDocShell::gNumberOfDocShells = 0;
#endif