fix for 4290
git-svn-id: svn://10.0.0.236/trunk@47632 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -145,7 +145,9 @@ nsresult nsGfxFactoryGTK::CreateInstance(nsISupports *aOuter,
|
||||
inst = (nsISupports *)new nsImageGTK();
|
||||
}
|
||||
else if (mClassID.Equals(kCRegion)) {
|
||||
inst = (nsISupports *)new nsRegionGTK();
|
||||
nsRegionGTK* dcs;
|
||||
NS_NEWXPCOM(dcs, nsRegionGTK);
|
||||
inst = (nsISupports *)dcs;
|
||||
}
|
||||
else if (mClassID.Equals(kCBlender)) {
|
||||
inst = (nsISupports *)new nsBlender;
|
||||
|
||||
@@ -29,7 +29,7 @@ class nsGraphicsState
|
||||
public:
|
||||
|
||||
nsTransform2D *mMatrix;
|
||||
nsRegionGTK *mClipRegion;
|
||||
nsIRegion *mClipRegion;
|
||||
nscolor mColor;
|
||||
nsLineStyle mLineStyle;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
|
||||
@@ -22,16 +22,30 @@
|
||||
#include "xregion.h"
|
||||
#include "prmem.h"
|
||||
|
||||
#ifdef DEBUG_REGIONS
|
||||
static int nRegions;
|
||||
#endif
|
||||
|
||||
nsRegionGTK::nsRegionGTK()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
|
||||
#ifdef DEBUG_REGIONS
|
||||
++nRegions;
|
||||
printf("REGIONS+ = %i\n", nRegions);
|
||||
#endif
|
||||
|
||||
mRegion = nsnull;
|
||||
mRegionType = eRegionComplexity_empty;
|
||||
}
|
||||
|
||||
nsRegionGTK::~nsRegionGTK()
|
||||
{
|
||||
#ifdef DEBUG_REGIONS
|
||||
--nRegions;
|
||||
printf("REGIONS- = %i\n", nRegions);
|
||||
#endif
|
||||
|
||||
if (mRegion)
|
||||
::gdk_region_destroy(mRegion);
|
||||
mRegion = nsnull;
|
||||
@@ -41,7 +55,6 @@ NS_IMPL_ISUPPORTS1(nsRegionGTK, nsIRegion)
|
||||
|
||||
nsresult nsRegionGTK::Init(void)
|
||||
{
|
||||
NS_ADDREF_THIS();
|
||||
mRegion = ::gdk_region_new();
|
||||
mRegionType = eRegionComplexity_empty;
|
||||
return NS_OK;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsRenderingContextGTK, nsIRenderingContext)
|
||||
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
|
||||
#define NSRECT_TO_GDKRECT(ns,gdk) \
|
||||
PR_BEGIN_MACRO \
|
||||
@@ -145,9 +146,11 @@ NS_IMETHODIMP nsRenderingContextGTK::CommonInit()
|
||||
gint x, y, w, h, d;
|
||||
gdk_window_get_geometry(mSurface->GetDrawable(), &x, &y, &w, &h, &d);
|
||||
|
||||
mClipRegion = new nsRegionGTK();
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0, 0, w, h);
|
||||
if ( NS_SUCCEEDED(nsComponentManager::CreateInstance(kRegionCID, 0, NS_GET_IID(nsIRegion), (void**)&mClipRegion)) )
|
||||
{
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0, 0, w, h);
|
||||
}
|
||||
|
||||
mContext->GetDevUnitsToAppUnits(mP2T);
|
||||
float app2dev;
|
||||
@@ -244,12 +247,8 @@ NS_IMETHODIMP nsRenderingContextGTK::PushState(void)
|
||||
|
||||
if (mClipRegion)
|
||||
{
|
||||
NS_IF_ADDREF(mClipRegion);
|
||||
state->mClipRegion = mClipRegion;
|
||||
|
||||
mClipRegion = new nsRegionGTK();
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(state->mClipRegion);
|
||||
// set the state's clip region to a new copy of the current clip region
|
||||
GetClipRegion(&state->mClipRegion);
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(mFontMetrics);
|
||||
@@ -277,9 +276,11 @@ NS_IMETHODIMP nsRenderingContextGTK::PopState(PRBool &aClipEmpty)
|
||||
delete mTMatrix;
|
||||
mTMatrix = state->mMatrix;
|
||||
|
||||
// get rid of the current clip region
|
||||
NS_IF_RELEASE(mClipRegion);
|
||||
mClipRegion = nsnull;
|
||||
|
||||
// restore everything
|
||||
// restore everything
|
||||
mClipRegion = state->mClipRegion;
|
||||
mFontMetrics = state->mFontMetrics;
|
||||
|
||||
@@ -456,23 +457,33 @@ NS_IMETHODIMP nsRenderingContextGTK::GetClipRegion(nsIRegion **aRegion)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
|
||||
|
||||
if (!aRegion)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (*aRegion) // copy it, they should be using CopyClipRegion
|
||||
{
|
||||
(*aRegion)->SetTo(*NS_STATIC_CAST(nsIRegion*, mClipRegion));
|
||||
printf("you should be calling CopyClipRegion()\n");
|
||||
(*aRegion)->SetTo(*mClipRegion);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( NS_SUCCEEDED(nsComponentManager::CreateInstance(kRegionCID, 0, NS_GET_IID(nsIRegion), (void**)*aRegion)) )
|
||||
if ( NS_SUCCEEDED(nsComponentManager::CreateInstance(kRegionCID, 0, NS_GET_IID(nsIRegion),
|
||||
(void**)aRegion )) )
|
||||
{
|
||||
(*aRegion)->Init();
|
||||
(*aRegion)->SetTo( *NS_STATIC_CAST(nsIRegion*, mClipRegion) );
|
||||
rv = NS_OK;
|
||||
if (mClipRegion)
|
||||
{
|
||||
(*aRegion)->Init();
|
||||
(*aRegion)->SetTo(*mClipRegion);
|
||||
NS_ADDREF(*aRegion);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("null clip region, can't make a valid copy\n");
|
||||
NS_RELEASE(*aRegion);
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@ protected:
|
||||
nsDrawingSurfaceGTK *mSurface;
|
||||
nsIDeviceContext *mContext;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsRegionGTK *mClipRegion;
|
||||
nsIRegion *mClipRegion;
|
||||
nsTransform2D *mTMatrix;
|
||||
float mP2T;
|
||||
GdkWChar* mDrawStringBuf;
|
||||
|
||||
Reference in New Issue
Block a user