diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 77ec88c82dd..292fefb5b37 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -554,6 +554,13 @@ 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/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 07cdbd4d172..d9da755b886 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -178,7 +178,6 @@ 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 @@ -7004,10 +7003,7 @@ PresShell::VerifyIncrementalReflow() PRBool isPaginated = PR_FALSE; mPresContext->IsPaginated(&isPaginated); if (isPaginated) { - nsCOMPtr ppx = do_CreateInstance(kPrintPreviewContextCID, &rv); - if (NS_SUCCEEDED(rv)) { - ppx->QueryInterface(NS_GET_IID(nsIPresContext),(void**)&cx); - } + rv = NS_NewPrintPreviewContext(&cx); } else { rv = NS_NewGalleyContext(&cx); diff --git a/layout/base/public/nsIPresContext.h b/layout/base/public/nsIPresContext.h index 77ec88c82dd..292fefb5b37 100644 --- a/layout/base/public/nsIPresContext.h +++ b/layout/base/public/nsIPresContext.h @@ -554,6 +554,13 @@ 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/layout/base/public/nsPresContext.h b/layout/base/public/nsPresContext.h index 77ec88c82dd..292fefb5b37 100644 --- a/layout/base/public/nsPresContext.h +++ b/layout/base/public/nsPresContext.h @@ -554,6 +554,13 @@ 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/layout/base/src/nsPrintPreviewContext.cpp b/layout/base/src/nsPrintPreviewContext.cpp index 6b319ac865d..1ab88a80d5c 100644 --- a/layout/base/src/nsPrintPreviewContext.cpp +++ b/layout/base/src/nsPrintPreviewContext.cpp @@ -43,9 +43,14 @@ #include "nsGfxCIID.h" #include "nsLayoutAtoms.h" #include "prlog.h" -#include "nsIPrintSettings.h" -class PrintPreviewContext : public nsPresContext, nsIPrintPreviewContext { +// Print Options +#include "nsIPrintOptions.h" +#include "nsGfxCIID.h" +#include "nsIServiceManager.h" +static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID); + +class PrintPreviewContext : public nsPresContext { public: PrintPreviewContext(); ~PrintPreviewContext(); @@ -61,13 +66,10 @@ 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() : @@ -145,27 +147,8 @@ 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(nsIPrintPreviewContext** aInstancePtrResult) +NS_NewPrintPreviewContext(nsIPresContext** aInstancePtrResult) { if (aInstancePtrResult == nsnull) { return NS_ERROR_NULL_POINTER; @@ -177,5 +160,5 @@ NS_NewPrintPreviewContext(nsIPrintPreviewContext** aInstancePtrResult) return NS_ERROR_OUT_OF_MEMORY; } - return it->QueryInterface(NS_GET_IID(nsIPrintPreviewContext), (void **) aInstancePtrResult); + return it->QueryInterface(NS_GET_IID(nsIPresContext), (void **) aInstancePtrResult); } diff --git a/layout/build/dlldeps.cpp b/layout/build/dlldeps.cpp index 39637c89b40..7a4ddf3bf32 100644 --- a/layout/build/dlldeps.cpp +++ b/layout/build/dlldeps.cpp @@ -42,7 +42,6 @@ #include "nsIPresShell.h" #include "nsIPrintContext.h" #include "nsIPresContext.h" -#include "nsIPrintPreviewContext.h" #include "nsIStyleSet.h" #include "nsIDocument.h" #include "nsHTMLParts.h" @@ -53,10 +52,9 @@ void XXXNeverCalled() nsIPresShell* ps; NS_NewPresShell(&ps); nsIPresContext* cx; - NS_NewGalleyContext(&cx); - nsIPrintPreviewContext *ppx; - NS_NewPrintPreviewContext(&ppx); nsIPrintContext *px; + NS_NewGalleyContext(&cx); + NS_NewPrintPreviewContext(&cx); NS_NewPrintContext(&px); nsIFrame* f; NS_NewTextFrame(ps, &f); diff --git a/layout/build/nsLayoutCID.h b/layout/build/nsLayoutCID.h index 95e602c2e20..7bdbb068747 100644 --- a/layout/build/nsLayoutCID.h +++ b/layout/build/nsLayoutCID.h @@ -126,10 +126,6 @@ #define NS_PRINTCONTEXT_CID \ { 0xa1fde85f, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } -// {A1FDE85F-E802-11d4-9885-00C04FA0CF4B} -#define NS_PRINTPREVIEWCONTEXT_CID \ -{ 0xdfd92dd, 0x19ff, 0x4e62, { 0x83, 0x16, 0x8e, 0x44, 0x3, 0x1a, 0x19, 0x62 } } - // {95F46161-D177-11d2-BF86-00105A1B0627} #define NS_HTML_CSS_STYLESHEET_CID \ { 0x95f46161, 0xd177, 0x11d2, { 0xbf, 0x86, 0x0, 0x10, 0x5a, 0x1b, 0x6, 0x27 } } diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index 366e1e8c17b..a3a3f892f34 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -50,7 +50,6 @@ #include "nsIPresShell.h" #include "nsIPresState.h" #include "nsIPrintContext.h" -#include "nsIPrintPreviewContext.h" #include "nsTextTransformer.h" #include "nsXBLAtoms.h" // to addref/release table @@ -210,6 +209,7 @@ 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,7 +217,6 @@ 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) @@ -283,11 +282,6 @@ static nsModuleComponentInfo gComponents[] = { NS_PRINTCONTEXT_CID, nsnull, CreateNewPrintContext }, - - { "Print Preview context", - NS_PRINTPREVIEWCONTEXT_CID, - nsnull, - CreateNewPrintPreviewContext }, // XXX end ick { "XUL Box Object", diff --git a/layout/html/base/src/nsPresShell.cpp b/layout/html/base/src/nsPresShell.cpp index 07cdbd4d172..d9da755b886 100644 --- a/layout/html/base/src/nsPresShell.cpp +++ b/layout/html/base/src/nsPresShell.cpp @@ -178,7 +178,6 @@ 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 @@ -7004,10 +7003,7 @@ PresShell::VerifyIncrementalReflow() PRBool isPaginated = PR_FALSE; mPresContext->IsPaginated(&isPaginated); if (isPaginated) { - nsCOMPtr ppx = do_CreateInstance(kPrintPreviewContextCID, &rv); - if (NS_SUCCEEDED(rv)) { - ppx->QueryInterface(NS_GET_IID(nsIPresContext),(void**)&cx); - } + rv = NS_NewPrintPreviewContext(&cx); } else { rv = NS_NewGalleyContext(&cx);