diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 292fefb5b37..77ec88c82dd 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.h @@ -554,13 +554,6 @@ public: extern NS_EXPORT nsresult NS_NewGalleyContext(nsIPresContext** aInstancePtrResult); -// Factory method to create a "paginated" presentation context for -// the screen. -extern NS_EXPORT nsresult - NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult); - - - #ifdef MOZ_REFLOW_PERF #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \ diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index d9da755b886..07cdbd4d172 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -178,6 +178,7 @@ static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID); static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); +static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID); // supporting bugs 31816, 20760, 22963 // define USE_OVERRIDE to put prefs in as an override stylesheet @@ -7003,7 +7004,10 @@ PresShell::VerifyIncrementalReflow() PRBool isPaginated = PR_FALSE; mPresContext->IsPaginated(&isPaginated); if (isPaginated) { - rv = NS_NewPrintPreviewContext(&cx); + nsCOMPtr ppx = do_CreateInstance(kPrintPreviewContextCID, &rv); + if (NS_SUCCEEDED(rv)) { + ppx->QueryInterface(NS_GET_IID(nsIPresContext),(void**)&cx); + } } else { rv = NS_NewGalleyContext(&cx); diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 292fefb5b37..77ec88c82dd 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.h @@ -554,13 +554,6 @@ public: extern NS_EXPORT nsresult NS_NewGalleyContext(nsIPresContext** aInstancePtrResult); -// Factory method to create a "paginated" presentation context for -// the screen. -extern NS_EXPORT nsresult - NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult); - - - #ifdef MOZ_REFLOW_PERF #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \ diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 292fefb5b37..77ec88c82dd 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.h @@ -554,13 +554,6 @@ public: extern NS_EXPORT nsresult NS_NewGalleyContext(nsIPresContext** aInstancePtrResult); -// Factory method to create a "paginated" presentation context for -// the screen. -extern NS_EXPORT nsresult - NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult); - - - #ifdef MOZ_REFLOW_PERF #define DO_GLOBAL_REFLOW_COUNT(_name, _type) \ diff --git a/mozilla/layout/base/src/nsPrintPreviewContext.cpp b/mozilla/layout/base/src/nsPrintPreviewContext.cpp index 1ab88a80d5c..6b319ac865d 100644 --- a/mozilla/layout/base/src/nsPrintPreviewContext.cpp +++ b/mozilla/layout/base/src/nsPrintPreviewContext.cpp @@ -43,14 +43,9 @@ #include "nsGfxCIID.h" #include "nsLayoutAtoms.h" #include "prlog.h" +#include "nsIPrintSettings.h" -// Print Options -#include "nsIPrintOptions.h" -#include "nsGfxCIID.h" -#include "nsIServiceManager.h" -static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); - -class PrintPreviewContext : public nsPresContext { +class PrintPreviewContext : public nsPresContext, nsIPrintPreviewContext { public: PrintPreviewContext(); ~PrintPreviewContext(); @@ -66,10 +61,13 @@ public: NS_IMETHOD GetPaginatedScrolling(PRBool* aResult); NS_IMETHOD GetPageDim(nsRect* aActualRect, nsRect* aAdjRect); NS_IMETHOD SetPageDim(nsRect* aRect); + NS_IMETHOD SetPrintSettings(nsIPrintSettings* aPS); + NS_IMETHOD GetPrintSettings(nsIPrintSettings** aPS); protected: nsRect mPageDim; PRBool mCanPaginatedScroll; + nsCOMPtr mPrintSettings; }; PrintPreviewContext::PrintPreviewContext() : @@ -147,8 +145,27 @@ PrintPreviewContext::SetPageDim(nsRect* aPageDim) return NS_OK; } +NS_IMETHODIMP +PrintPreviewContext::SetPrintSettings(nsIPrintSettings * aPrintSettings) +{ + NS_ENSURE_ARG_POINTER(aPrintSettings); + mPrintSettings = aPrintSettings; + return NS_OK; +} + +NS_IMETHODIMP +PrintPreviewContext::GetPrintSettings(nsIPrintSettings * *aPrintSettings) +{ + NS_ENSURE_ARG_POINTER(aPrintSettings); + + *aPrintSettings = mPrintSettings; + NS_IF_ADDREF(*aPrintSettings); + + return NS_OK; +} + NS_EXPORT nsresult -NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult) +NS_NewPrintPreviewContext(nsIPrintPreviewContext** aInstancePtrResult) { if (aInstancePtrResult == nsnull) { return NS_ERROR_NULL_POINTER; @@ -160,5 +177,5 @@ NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult) return NS_ERROR_OUT_OF_MEMORY; } - return it->QueryInterface(NS_GET_IID(nsIPresContext), (void **) aInstancePtrResult); + return it->QueryInterface(NS_GET_IID(nsIPrintPreviewContext), (void **) aInstancePtrResult); } diff --git a/mozilla/layout/build/dlldeps.cpp b/mozilla/layout/build/dlldeps.cpp index 7a4ddf3bf32..39637c89b40 100644 --- a/mozilla/layout/build/dlldeps.cpp +++ b/mozilla/layout/build/dlldeps.cpp @@ -42,6 +42,7 @@ #include "nsIPresShell.h" #include "nsIPrintContext.h" #include "nsIPresContext.h" +#include "nsIPrintPreviewContext.h" #include "nsIStyleSet.h" #include "nsIDocument.h" #include "nsHTMLParts.h" @@ -52,9 +53,10 @@ void XXXNeverCalled() nsIPresShell* ps; NS_NewPresShell(&ps); nsIPresContext* cx; - nsIPrintContext *px; NS_NewGalleyContext(&cx); - NS_NewPrintPreviewContext(&cx); + nsIPrintPreviewContext *ppx; + NS_NewPrintPreviewContext(&ppx); + nsIPrintContext *px; NS_NewPrintContext(&px); nsIFrame* f; NS_NewTextFrame(ps, &f); diff --git a/mozilla/layout/build/nsLayoutModule.cpp b/mozilla/layout/build/nsLayoutModule.cpp index a3a3f892f34..ba4939c67e3 100644 --- a/mozilla/layout/build/nsLayoutModule.cpp +++ b/mozilla/layout/build/nsLayoutModule.cpp @@ -50,6 +50,7 @@ #include "nsIPresShell.h" #include "nsIPresState.h" #include "nsIPrintContext.h" +#include "nsIPrintPreviewContext.h" #include "nsTextTransformer.h" #include "nsXBLAtoms.h" // to addref/release table @@ -209,7 +210,6 @@ MAKE_CTOR(CreateNewFrameUtil, nsIFrameUtil, NS_NewFrameUtil) MAKE_CTOR(CreateNewLayoutDebugger, nsILayoutDebugger, NS_NewLayoutDebugger) #endif -MAKE_CTOR(CreateNewPrintPreviewContext, nsIPresContext, NS_NewPrintPreviewContext) MAKE_CTOR(CreateNewCSSFrameConstructor, nsICSSFrameConstructor, NS_CreateCSSFrameConstructor) MAKE_CTOR(CreateNewFrameTraversal, nsIFrameTraversal, NS_CreateFrameTraversal) MAKE_CTOR(CreateNewLayoutHistoryState, nsILayoutHistoryState, NS_NewLayoutHistoryState) @@ -217,6 +217,7 @@ MAKE_CTOR(CreateNewPresShell, nsIPresShell, NS_NewPresShell) MAKE_CTOR(CreateNewPresState, nsIPresState, NS_NewPresState) MAKE_CTOR(CreateNewGalleyContext, nsIPresContext, NS_NewGalleyContext) MAKE_CTOR(CreateNewPrintContext, nsIPrintContext, NS_NewPrintContext) +MAKE_CTOR(CreateNewPrintPreviewContext, nsIPrintPreviewContext, NS_NewPrintPreviewContext) MAKE_CTOR(CreateNewBoxObject, nsIBoxObject, NS_NewBoxObject) MAKE_CTOR(CreateNewTreeBoxObject, nsIBoxObject, NS_NewTreeBoxObject) MAKE_CTOR(CreateNewMenuBoxObject, nsIBoxObject, NS_NewMenuBoxObject) @@ -242,11 +243,6 @@ static nsModuleComponentInfo gComponents[] = { CreateNewLayoutDebugger }, #endif - { "Print preview context", - NS_PRINT_PREVIEW_CONTEXT_CID, - nsnull, - CreateNewPrintPreviewContext }, - { "CSS Frame Constructor", NS_CSSFRAMECONSTRUCTOR_CID, nsnull, @@ -282,6 +278,11 @@ static nsModuleComponentInfo gComponents[] = { NS_PRINTCONTEXT_CID, nsnull, CreateNewPrintContext }, + + { "Print Preview context", + NS_PRINT_PREVIEW_CONTEXT_CID, + nsnull, + CreateNewPrintPreviewContext }, // XXX end ick { "XUL Box Object", diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index d9da755b886..07cdbd4d172 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -178,6 +178,7 @@ static NS_DEFINE_CID(kCSSStyleSheetCID, NS_CSS_STYLESHEET_CID); static NS_DEFINE_CID(kStyleSetCID, NS_STYLESET_CID); static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); +static NS_DEFINE_CID(kPrintPreviewContextCID, NS_PRINT_PREVIEW_CONTEXT_CID); // supporting bugs 31816, 20760, 22963 // define USE_OVERRIDE to put prefs in as an override stylesheet @@ -7003,7 +7004,10 @@ PresShell::VerifyIncrementalReflow() PRBool isPaginated = PR_FALSE; mPresContext->IsPaginated(&isPaginated); if (isPaginated) { - rv = NS_NewPrintPreviewContext(&cx); + nsCOMPtr ppx = do_CreateInstance(kPrintPreviewContextCID, &rv); + if (NS_SUCCEEDED(rv)) { + ppx->QueryInterface(NS_GET_IID(nsIPresContext),(void**)&cx); + } } else { rv = NS_NewGalleyContext(&cx);