clamp down sizes < 2^15 r=dbaron@fas.harvard.edu r=paulmac ;) fixes bug 2564

This commit is contained in:
pavlov%netscape.com 1999-11-02 03:38:23 +00:00
Родитель 6c20d026a7
Коммит 7087d8e044
2 изменённых файлов: 41 добавлений и 0 удалений

Просмотреть файл

@ -737,6 +737,11 @@ NS_IMETHODIMP nsRenderingContextGTK::DrawRect(nscoord aX, nscoord aY, nscoord aW
mTMatrix->TransformCoord(&x,&y,&w,&h);
// After the transform, if the numbers are huge, chop them, because
// they're going to be converted from 32 bit to 16 bit.
// It's all way off the screen anyway.
ConditionRect(x,y,w,h);
// Don't draw empty rectangles; also, w/h are adjusted down by one
// so that the right number of pixels are drawn.
if (w && h) {
@ -770,6 +775,11 @@ NS_IMETHODIMP nsRenderingContextGTK::FillRect(nscoord aX, nscoord aY, nscoord aW
mTMatrix->TransformCoord(&x,&y,&w,&h);
// After the transform, if the numbers are huge, chop them, because
// they're going to be converted from 32 bit to 16 bit.
// It's all way off the screen anyway.
ConditionRect(x,y,w,h);
::gdk_draw_rectangle(mSurface->GetDrawable(), mSurface->GetGC(),
TRUE,
x, y, w, h);
@ -797,6 +807,11 @@ NS_IMETHODIMP nsRenderingContextGTK::InvertRect(nscoord aX, nscoord aY, nscoord
mTMatrix->TransformCoord(&x,&y,&w,&h);
// After the transform, if the numbers are huge, chop them, because
// they're going to be converted from 32 bit to 16 bit.
// It's all way off the screen anyway.
ConditionRect(x,y,w,h);
// Set XOR drawing mode
::gdk_gc_set_function(mSurface->GetGC(),GDK_XOR);
@ -1582,3 +1597,24 @@ NS_IMETHODIMP nsRenderingContextGTK::RetrieveCurrentNativeGraphicData(PRUint32 *
{
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextGTK::ConditionRect( nscoord &x, nscoord &y, nscoord &w, nscoord &h )
{
if ( y < -32766 ) {
y = -32766;
}
if ( y + h > 32766 ) {
h = 32766 - y;
}
if ( x < -32766 ) {
x = -32766;
}
if ( x + w > 32766 ) {
w = 32766 - x;
}
return NS_OK;
}

Просмотреть файл

@ -174,6 +174,11 @@ protected:
nscolor mCurrentColor;
GdkFont *mCurrentFont;
nsLineStyle mCurrentLineStyle;
private:
// ConditionRect is used to fix coordinate overflow problems for
// rectangles after they are transformed to screen coordinates
NS_IMETHOD ConditionRect( nscoord &x, nscoord &y, nscoord &w, nscoord &h );
};
#endif /* nsRenderingContextGTK_h___ */