From abd275880c238f90e1b9929994f6059dfe3065cd Mon Sep 17 00:00:00 2001 From: "pierre%netscape.com" Date: Thu, 21 Jan 1999 08:41:21 +0000 Subject: [PATCH] initialize the Rendering Context from a GrafPort to fix a crash on print --- gfx/src/mac/nsDeviceContextMac.cpp | 2 +- gfx/src/mac/nsRenderingContextMac.cpp | 18 ++++++++++++++++++ gfx/src/mac/nsRenderingContextMac.h | 1 + widget/src/mac/nsDeviceContextMac.cpp | 2 +- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gfx/src/mac/nsDeviceContextMac.cpp b/gfx/src/mac/nsDeviceContextMac.cpp index 7a436e5a67a1..3fb62493d1e6 100644 --- a/gfx/src/mac/nsDeviceContextMac.cpp +++ b/gfx/src/mac/nsDeviceContextMac.cpp @@ -80,7 +80,7 @@ double pix_inch; */ NS_IMETHODIMP nsDeviceContextMac :: CreateRenderingContext(nsIRenderingContext *&aContext) { -nsIRenderingContext *pContext; +nsRenderingContextMac *pContext; nsresult rv; GrafPtr thePort; diff --git a/gfx/src/mac/nsRenderingContextMac.cpp b/gfx/src/mac/nsRenderingContextMac.cpp index 9466c5f0186f..52519cd6ed24 100644 --- a/gfx/src/mac/nsRenderingContextMac.cpp +++ b/gfx/src/mac/nsRenderingContextMac.cpp @@ -464,6 +464,24 @@ NS_IMETHODIMP nsRenderingContextMac::Init(nsIDeviceContext* aContext, nsDrawingS //------------------------------------------------------------------------ +// used by nsDeviceContextMac::CreateRenderingContext() for printing +nsresult nsRenderingContextMac::Init(nsIDeviceContext* aContext, GrafPtr aPort) +{ + mContext = aContext; + NS_IF_ADDREF(mContext); + + if (mOriginalSurface->GetPort() == nsnull) + mOriginalSurface->Init(aPort); + + // select the surface + mFrontSurface->Init(aPort); + SelectDrawingSurface(mFrontSurface); + + return NS_OK; +} + +//------------------------------------------------------------------------ + void nsRenderingContextMac::SelectDrawingSurface(DrawingSurface* aSurface) { if (! aSurface) diff --git a/gfx/src/mac/nsRenderingContextMac.h b/gfx/src/mac/nsRenderingContextMac.h index e82dcda9fe77..480cef700605 100644 --- a/gfx/src/mac/nsRenderingContextMac.h +++ b/gfx/src/mac/nsRenderingContextMac.h @@ -111,6 +111,7 @@ public: //locals NS_IMETHOD SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty); NS_IMETHOD SetPortTextState(); + nsresult Init(nsIDeviceContext* aContext, GrafPtr aPort); protected: void SelectDrawingSurface(DrawingSurface* aSurface); diff --git a/widget/src/mac/nsDeviceContextMac.cpp b/widget/src/mac/nsDeviceContextMac.cpp index 7a436e5a67a1..3fb62493d1e6 100644 --- a/widget/src/mac/nsDeviceContextMac.cpp +++ b/widget/src/mac/nsDeviceContextMac.cpp @@ -80,7 +80,7 @@ double pix_inch; */ NS_IMETHODIMP nsDeviceContextMac :: CreateRenderingContext(nsIRenderingContext *&aContext) { -nsIRenderingContext *pContext; +nsRenderingContextMac *pContext; nsresult rv; GrafPtr thePort;