Skip to content

Instantly share code, notes, and snippets.

@jviereck
Created May 18, 2012 20:05
Show Gist options
  • Save jviereck/2727337 to your computer and use it in GitHub Desktop.
Save jviereck/2727337 to your computer and use it in GitHub Desktop.
# HG changeset patch
# Parent 35a07c3f3ca1f76e8e5b8cb32a646e569beafa49
diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp
--- a/layout/printing/nsPrintEngine.cpp
+++ b/layout/printing/nsPrintEngine.cpp
@@ -1867,16 +1869,72 @@ nsPrintEngine::ReflowDocList(nsPrintObje
PRInt32 cnt = aPO->mKids.Length();
for (PRInt32 i=0;i<cnt;i++) {
rv = ReflowDocList(aPO->mKids[i], aSetPixelScale);
NS_ENSURE_SUCCESS(rv, rv);
}
return NS_OK;
}
+////////////////////////////////////////////////////////////////////////////////
+// nsIWebProgressListener
+
+NS_IMETHODIMP
+nsPrintEngine::OnStateChange(nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest, PRUint32 aStateFlags,
+ nsresult aStatus)
+{
+ if ((aStateFlags & STATE_START) != 0) {
+ printf("nsPrintEngine - startRequest\n");
+ }
+ if ((aStateFlags & STATE_STOP) != 0) {
+ printf("nsPrintEngine - stopRequest\n");
+ }
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintEngine::OnProgressChange(nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ PRInt32 aCurSelfProgress,
+ PRInt32 aMaxSelfProgress,
+ PRInt32 aCurTotalProgress,
+ PRInt32 aMaxTotalProgress)
+{
+ NS_NOTREACHED("notification excluded in AddProgressListener(...)");
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintEngine::OnLocationChange(nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest, nsIURI *aLocation,
+ PRUint32 aFlags)
+{
+ NS_NOTREACHED("notification excluded in AddProgressListener(...)");
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintEngine::OnStatusChange(nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest, nsresult aStatus,
+ const PRUnichar *aMessage)
+{
+ NS_NOTREACHED("notification excluded in AddProgressListener(...)");
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsPrintEngine::OnSecurityChange(nsIWebProgress *aWebProgress,
+ nsIRequest *aRequest,
+ PRUint32 aState)
+{
+ NS_NOTREACHED("notification excluded in AddProgressListener(...)");
+ return NS_OK;
+}
+
//-------------------------------------------------------
// Reflow a nsPrintObject
nsresult
nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO)
{
NS_ASSERTION(aPO, "Pointer is null!");
if (!aPO) return NS_ERROR_FAILURE;
@@ -1990,16 +2048,25 @@ nsPrintEngine::ReflowPrintObject(nsPrint
// This docshell stuff is weird; will go away when we stop having multiple
// presentations per document
nsCOMPtr<nsISupports> supps(do_QueryInterface(aPO->mDocShell));
aPO->mPresContext->SetContainer(supps);
aPO->mPresShell->BeginObservingDocument();
+ /*
+ nsCOMPtr<nsIWebProgress> webProgress = do_QueryInterface(aPO->mDocShell);
+ // do_QueryInterface(nsDocLoader::GetAsSupports(aPO->mDocShell));
+ //static_cast<nsCOMPtr<nsIWebProgress>>(aPO->mPresShell)->AddProgressListener(
+
+ webProgress->AddProgressListener(
+ static_cast<nsIWebProgressListener*>(this),
+ nsIWebProgress::NOTIFY_STATE_NETWORK);
+ */
printf("Update mZoomRation\n");
if (mIsCreatingPrintPreview && documentIsTopLevel) {
mDocViewerPrint->SetPrintPreviewPresentation(aPO->mViewManager,
aPO->mPresContext,
aPO->mPresShell);
}
diff --git a/layout/printing/nsPrintEngine.h b/layout/printing/nsPrintEngine.h
--- a/layout/printing/nsPrintEngine.h
+++ b/layout/printing/nsPrintEngine.h
@@ -45,35 +45,41 @@
#include "nsPrintData.h"
#include "nsFrameList.h"
// Interfaces
#include "nsIDocument.h"
#include "nsIDOMWindow.h"
#include "nsIObserver.h"
+#include "nsIWebProgress.h"
+#include "nsIWebProgressListener.h"
+
// Classes
class nsPagePrintTimer;
class nsIDocShellTreeNode;
class nsDeviceContext;
class nsIDocumentViewerPrint;
class nsPrintObject;
class nsIDocShell;
class nsIPageSequenceFrame;
class nsIWeakReference;
+class nsIWebProgressListener;
//------------------------------------------------------------------------
// nsPrintEngine Class
//
//------------------------------------------------------------------------
-class nsPrintEngine : public nsIObserver
+class nsPrintEngine : public nsIWebProgressListener,
+ public nsIObserver
{
public:
// nsISupports interface...
NS_DECL_ISUPPORTS
+ NS_DECL_NSIWEBPROGRESSLISTENER
// nsIObserver
NS_DECL_NSIOBSERVER
// Old nsIWebBrowserPrint methods; not cleaned up yet
NS_IMETHOD Print(nsIPrintSettings* aPrintSettings,
nsIWebProgressListener* aWebProgressListener);
NS_IMETHOD PrintPreview(nsIPrintSettings* aPrintSettings,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment