mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 04:58:00 +00:00
Fix for bug 120228. The rendering context made for the caret was interferring with the origin and clipping of the drawing port. To fix this, we have to reset these before reach drawing call. r=pinkerton, sr=kin, a=asa
This commit is contained in:
parent
2476e6118c
commit
e99044efd2
@ -254,7 +254,7 @@ void nsRenderingContextMac::SelectDrawingSurface(nsDrawingSurfaceMac* aSurface,
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::SetPortTextState()
|
||||
nsresult nsRenderingContextMac::SetPortTextState()
|
||||
{
|
||||
NS_PRECONDITION(mGS->mFontMetrics != nsnull, "No font metrics in SetPortTextState");
|
||||
|
||||
@ -277,6 +277,15 @@ NS_IMETHODIMP nsRenderingContextMac::SetPortTextState()
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void nsRenderingContextMac::SetupPortState()
|
||||
{
|
||||
nsGraphicsUtils::SafeSetPort(mPort);
|
||||
::SetOrigin(-mGS->mOffx, -mGS->mOffy);
|
||||
::SetClip(mGS->mClipRegion);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
@ -445,9 +454,9 @@ NS_IMETHODIMP nsRenderingContextMac::CopyOffScreenBits(nsDrawingSurface aSrcSurf
|
||||
mFrontSurface->GetGrafPtr(&destPort);
|
||||
}
|
||||
|
||||
// set the port to the destination for CopyBits
|
||||
StPortSetter portSetter(destPort);
|
||||
|
||||
// we need to select the front surface so that the coordinates are set up correctly
|
||||
SelectDrawingSurface(destSurface);
|
||||
|
||||
// set the right colors for CopyBits
|
||||
RGBColor foreColor;
|
||||
Boolean changedForeColor = false;
|
||||
@ -500,9 +509,11 @@ NS_IMETHODIMP nsRenderingContextMac::CreateDrawingSurface(nsRect *aBounds, PRUin
|
||||
if (aBounds != nsnull) {
|
||||
// fyi, aBounds->x and aBounds->y are always 0 here
|
||||
::SetRect(&macRect, aBounds->x, aBounds->y, aBounds->XMost(), aBounds->YMost());
|
||||
} else
|
||||
} else {
|
||||
NS_ASSERTION(0, "Creating empty surface");
|
||||
::SetRect(&macRect, 0, 0, 2, 2);
|
||||
|
||||
}
|
||||
|
||||
nsDrawingSurfaceMac* surface = new nsDrawingSurfaceMac();
|
||||
if (!surface)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -739,7 +750,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetClipRegion(nsIRegion **aRegion)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::SetColor(nscolor aColor)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
#define COLOR8TOCOLOR16(color8) ((color8 << 8) | color8)
|
||||
|
||||
@ -847,7 +858,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetCurrentTransform(nsTransform2D *&aTransf
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
mGS->mTMatrix.TransformCoord(&aX0,&aY0);
|
||||
mGS->mTMatrix.TransformCoord(&aX1,&aY1);
|
||||
@ -873,7 +884,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawLine(nscoord aX0, nscoord aY0, nscoord
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
// make the line one pixel shorter to match other platforms
|
||||
nscoord diffX = aX1 - aX0;
|
||||
@ -896,7 +907,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawStdLine(nscoord aX0, nscoord aY0, nscoo
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
PRUint32 i;
|
||||
PRInt32 x,y;
|
||||
@ -946,7 +957,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawRect(const nsRect& aRect)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
@ -974,7 +985,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillRect(const nsRect& aRect)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
@ -996,7 +1007,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillRect(nscoord aX, nscoord aY, nscoord aW
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
PRUint32 i;
|
||||
PolyHandle thepoly;
|
||||
@ -1032,7 +1043,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt3
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
PRUint32 i;
|
||||
PolyHandle thepoly;
|
||||
@ -1073,7 +1084,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawEllipse(const nsRect& aRect)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
@ -1101,7 +1112,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillEllipse(const nsRect& aRect)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
@ -1131,7 +1142,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawArc(const nsRect& aRect,
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
float aStartAngle, float aEndAngle)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
@ -1161,7 +1172,7 @@ NS_IMETHODIMP nsRenderingContextMac::FillArc(const nsRect& aRect,
|
||||
NS_IMETHODIMP nsRenderingContextMac::FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
float aStartAngle, float aEndAngle)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
@ -1224,7 +1235,7 @@ NS_IMETHODIMP nsRenderingContextMac::GetWidth(const char *aString, nscoord &aWid
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextMac::GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
// set native font and attributes
|
||||
SetPortTextState();
|
||||
@ -1243,7 +1254,7 @@ nsRenderingContextMac::GetWidth(const char* aString, PRUint32 aLength, nscoord&
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth, PRInt32 *aFontID)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nsresult rv = SetPortTextState();
|
||||
if (NS_FAILED(rv))
|
||||
@ -1275,7 +1286,7 @@ NS_IMETHODIMP
|
||||
nsRenderingContextMac::GetTextDimensions(const PRUnichar* aString, PRUint32 aLength,
|
||||
nsTextDimensions& aDimensions, PRInt32* aFontID)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nsresult rv = SetPortTextState();
|
||||
if (NS_FAILED(rv))
|
||||
@ -1295,7 +1306,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawString(const char *aString, PRUint32 aL
|
||||
nscoord aX, nscoord aY,
|
||||
const nscoord* aSpacing)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
PRInt32 x = aX;
|
||||
PRInt32 y = aY;
|
||||
@ -1342,7 +1353,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawString(const PRUnichar *aString, PRUint
|
||||
nscoord aX, nscoord aY, PRInt32 aFontID,
|
||||
const nscoord* aSpacing)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nsresult rv = SetPortTextState();
|
||||
if (NS_FAILED(rv))
|
||||
@ -1402,7 +1413,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, nscoord aX, nsc
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nsRect sr = aSRect;
|
||||
nsRect dr = aDRect;
|
||||
@ -1419,7 +1430,7 @@ NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& a
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::DrawImage(nsIImage *aImage, const nsRect& aRect)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nsRect tr = aRect;
|
||||
mGS->mTMatrix.TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
|
||||
@ -1454,7 +1465,7 @@ NS_IMETHODIMP nsRenderingContextMac::InvertRect(const nsRect& aRect)
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextMac::InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
StPortSetter setter(mPort);
|
||||
SetupPortState();
|
||||
|
||||
nscoord x,y,w,h;
|
||||
Rect therect;
|
||||
|
@ -184,7 +184,7 @@ public:
|
||||
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
|
||||
#endif // IBMBIDI
|
||||
//locals
|
||||
NS_IMETHOD SetPortTextState();
|
||||
nsresult SetPortTextState();
|
||||
nsresult Init(nsIDeviceContext* aContext, CGrafPtr aPort);
|
||||
|
||||
protected:
|
||||
@ -197,21 +197,22 @@ protected:
|
||||
};
|
||||
|
||||
void SelectDrawingSurface(nsDrawingSurfaceMac* aSurface, PRUint32 aChanges = kEverythingChanged);
|
||||
void SetupPortState();
|
||||
|
||||
protected:
|
||||
float mP2T; // Pixel to Twip conversion factor
|
||||
nsIDeviceContext * mContext;
|
||||
float mP2T; // Pixel to Twip conversion factor
|
||||
nsIDeviceContext * mContext;
|
||||
|
||||
nsDrawingSurfaceMac* mFrontSurface;
|
||||
nsDrawingSurfaceMac* mCurrentSurface; // pointer to the current surface
|
||||
nsDrawingSurfaceMac* mFrontSurface;
|
||||
nsDrawingSurfaceMac* mCurrentSurface; // pointer to the current surface
|
||||
|
||||
CGrafPtr mPort; // current grafPort - shortcut for mCurrentSurface->GetPort()
|
||||
nsGraphicState * mGS; // current graphic state - shortcut for mCurrentSurface->GetGS()
|
||||
nsUnicodeRenderingToolkit mUnicodeRenderingToolkit;
|
||||
nsGraphicState * mGS; // current graphic state - shortcut for mCurrentSurface->GetGS()
|
||||
nsUnicodeRenderingToolkit mUnicodeRenderingToolkit;
|
||||
nsAutoVoidArray mGSStack; // GraphicStates stack, used for PushState/PopState
|
||||
PRUint32 mChanges; // bit mask of attributes that have changed since last Push().
|
||||
PRUint32 mChanges; // bit mask of attributes that have changed since last Push().
|
||||
#ifdef IBMBIDI
|
||||
PRBool mRightToLeftText;
|
||||
PRBool mRightToLeftText;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user