Bug 241140

Consolidate DrawImage and DrawScaledImage
r=biesi sr=tor
This commit is contained in:
caillon%redhat.com 2004-05-04 01:32:26 +00:00
parent 2b2397bfaa
commit 4a50b6abeb
17 changed files with 79 additions and 219 deletions

View File

@ -804,11 +804,16 @@ public:
*/
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL) = 0;
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint) = 0;
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect) = 0;
/**
* Draw an image, scaling it to fit a specified rectangle.
* @param aImage The image to draw
* @param aSrcRect The portion (in twips) of the image to draw.
* [x,y] denotes the top left corner of the region.
* @param aDestRect The region (in twips) of the page that the image should
* occupy. [x,y] denotes the top left corner.
* [height,width] denotes the desired image size.
*/
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect) = 0;
/*
* Tiles an image over an area

View File

@ -1458,16 +1458,10 @@ nsRenderingContextGTK::GetBoundingMetrics(const PRUnichar* aString,
#endif /* MOZ_MATHML */
NS_IMETHODIMP nsRenderingContextGTK::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
NS_IMETHODIMP nsRenderingContextGTK::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
UpdateGC();
return nsRenderingContextImpl::DrawImage(aImage, aSrcRect, aDestPoint);
}
NS_IMETHODIMP nsRenderingContextGTK::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
UpdateGC();
return nsRenderingContextImpl::DrawScaledImage(aImage, aSrcRect, aDestRect);
return nsRenderingContextImpl::DrawImage(aImage, aSrcRect, aDestRect);
}
NS_IMETHODIMP nsRenderingContextGTK::GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer)

View File

@ -193,8 +193,7 @@ public:
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer);
NS_IMETHOD ReleaseBackbuffer(void);

View File

@ -133,8 +133,7 @@ public:
*/
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
NS_IMETHOD DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect);
NS_IMETHOD RenderPostScriptDataFragment(const unsigned char *aData, unsigned long aDatalen);

View File

@ -1228,27 +1228,16 @@ nsRenderingContextPS :: DrawString(const nsString& aString,nscoord aX, nscoord a
return DrawString(aString.get(), aString.Length(), aX, aY, aFontID, aSpacing);
}
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
NS_IMETHODIMP
nsRenderingContextPS::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
nsRenderingContextPS::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
nsRect dr(aDestPoint->x, aDestPoint->y, aSrcRect->width, aSrcRect->height);
return DrawScaledImage(aImage, aSrcRect, &dr);
}
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHODIMP
nsRenderingContextPS::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
nsRect sr, ir, dr;
// Transform the destination rectangle.
dr = *aDestRect;
nsRect dr = aDestRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
// Transform the source rectangle. We don't use the matrix for this;
// just convert the twips back into points.
sr = *aSrcRect;
nsRect sr = aSrcRect;
sr.x /= TWIPS_PER_POINT_INT;
sr.y /= TWIPS_PER_POINT_INT;
sr.width /= TWIPS_PER_POINT_INT;
@ -1261,6 +1250,7 @@ nsRenderingContextPS::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrc
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img) return NS_ERROR_FAILURE;
nsRect ir;
iframe->GetRect(ir);
mPSObj->draw_image(img, sr, ir, dr);
return NS_OK;

View File

@ -196,28 +196,17 @@ public:
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
/** ---------------------------------------------------
* Draw an image
* @param aImage The image to draw
* aSrcRect The portion of the image to draw. [x,y] denotes
* the top left corner of the region.
* aDestPoint The location of the image on the page. [x,y] denotes
* the top left corner.
*/
NS_IMETHOD DrawImage(imgIContainer *aImage,
const nsRect * aSrcRect, const nsPoint * aDestPoint);
/** ---------------------------------------------------
* Draw an image, scaling it to fit a specified rectangle.
* @param aImage The image to draw
* aSrcRect The portion of the image to draw. [x,y] denotes
* the top left corner of the region.
* aDestPoint The region of the page that the image should
* aDestRect The region of the page that the image should
* occupy. [x,y] denotes the top left corner.
* [height,width] denotes the image size.
*/
NS_IMETHOD DrawScaledImage(imgIContainer *aImage,
const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawImage(imgIContainer *aImage,
const nsRect & aSrcRect, const nsRect & aDestRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);

View File

@ -743,88 +743,19 @@ float avx,avy,av1x,av1y;
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
NS_IMETHODIMP nsRenderingContextImpl::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
NS_IMETHODIMP nsRenderingContextImpl::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
nsPoint pt;
nsRect sr;
float fX = float(aDestPoint->x), fY = float(aDestPoint->y);
mTranMatrix->Transform(&fX, &fY);
pt.x = NSToCoordRound(fX);
pt.y = NSToCoordRound(fY);
sr = *aSrcRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
sr.x = aSrcRect->x;
sr.y = aSrcRect->y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
if (!iframe) return NS_ERROR_FAILURE;
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img) return NS_ERROR_FAILURE;
nsIDrawingSurface *surface = nsnull;
GetDrawingSurface((void**)&surface);
if (!surface) return NS_ERROR_FAILURE;
// For Bug 87819
// iframe may want image to start at different position, so adjust
nsRect iframeRect;
iframe->GetRect(iframeRect);
if (iframeRect.y > 0) {
sr.y -= iframeRect.y;
if (sr.y < 0) {
pt.y = pt.y - sr.y;
sr.height = sr.height + sr.y;
if (sr.height < 0)
return NS_OK;
sr.y = 0;
} else if (sr.y > iframeRect.height) {
return NS_OK;
}
}
if (iframeRect.x > 0) {
sr.x -= iframeRect.x;
if (sr.x < 0) {
pt.x = pt.x - sr.x;
sr.width = sr.width + sr.x;
if (sr.width < 0)
return NS_OK;
sr.x = 0;
} else if (sr.x > iframeRect.width) {
return NS_OK;
}
}
return img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height,
pt.x, pt.y, sr.width, sr.height);
}
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
nsRect dr;
nsRect sr;
dr = *aDestRect;
nsRect dr = aDestRect;
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
sr = *aSrcRect;
nsRect sr = aSrcRect;
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
if (sr.width <= 0 || sr.height <= 0 || dr.width <= 0 || dr.height <= 0)
if (sr.IsEmpty() || dr.IsEmpty())
return NS_OK;
sr.x = aSrcRect->x;
sr.y = aSrcRect->y;
sr.x = aSrcRect.x;
sr.y = aSrcRect.y;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
nsCOMPtr<gfxIImageFrame> iframe;
@ -844,12 +775,16 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, con
iframe->GetRect(iframeRect);
if (iframeRect.x > 0) {
float xScaleRatio = float(dr.width) / sr.width;
nscoord scaled_x = sr.x;
if (dr.width != sr.width) {
PRFloat64 scale_ratio = PRFloat64(dr.width) / PRFloat64(sr.width);
scaled_x = NSToCoordRound(scaled_x * scale_ratio);
}
sr.x -= iframeRect.x;
if (sr.x < 0) {
dr.x -= NSToIntRound(sr.x * xScaleRatio);
dr.x -= scaled_x;
sr.width += sr.x;
dr.width += NSToIntRound(sr.x * xScaleRatio);
dr.width += scaled_x;
if (sr.width <= 0 || dr.width <= 0)
return NS_OK;
sr.x = 0;
@ -859,21 +794,26 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, con
}
if (iframeRect.y > 0) {
float yScaleRatio = float(dr.height) / sr.height;
nscoord scaled_y = sr.y;
if (dr.height != sr.height) {
PRFloat64 scale_ratio = PRFloat64(dr.height) / PRFloat64(sr.height);
scaled_y = NSToCoordRound(scaled_y * scale_ratio);
}
// adjust for offset
sr.y -= iframeRect.y;
if (sr.y < 0) {
dr.y -= NSToIntRound(sr.y * yScaleRatio);
dr.y -= scaled_y;
sr.height += sr.y;
dr.height += NSToIntRound(sr.y * yScaleRatio);
dr.height += scaled_y;
if (sr.height <= 0 || dr.height <= 0)
return NS_OK;
sr.y = 0;
} else if (sr.y > iframeRect.height) {
return NS_OK;
}
}
}
return img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height,
dr.x, dr.y, dr.width, dr.height);
}

View File

@ -2533,19 +2533,11 @@ nsRenderingContextXlib::GetBoundingMetrics(const PRUnichar* aString,
#endif /* MOZ_MATHML */
NS_IMETHODIMP
nsRenderingContextXlib::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
nsRenderingContextXlib::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
UpdateGC();
return nsRenderingContextImpl::DrawImage(aImage, aSrcRect, aDestPoint);
}
NS_IMETHODIMP
nsRenderingContextXlib::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawScaledImage()\n"));
UpdateGC();
return nsRenderingContextImpl::DrawScaledImage(aImage, aSrcRect, aDestRect);
return nsRenderingContextImpl::DrawImage(aImage, aSrcRect, aDestRect);
}
NS_IMETHODIMP

View File

@ -193,8 +193,7 @@ public:
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer);
NS_IMETHOD ReleaseBackbuffer(void);

View File

@ -151,39 +151,9 @@ nsRenderingContextXp::CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurf
return NS_OK;
}
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
NS_IMETHODIMP nsRenderingContextXp::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
NS_IMETHODIMP nsRenderingContextXp::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawImage()\n"));
nsPoint pt;
nsRect sr;
pt = *aDestPoint;
mTranMatrix->TransformCoord(&pt.x, &pt.y);
sr = *aSrcRect;
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
nsCOMPtr<gfxIImageFrame> iframe;
aImage->GetCurrentFrame(getter_AddRefs(iframe));
if (!iframe)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
if (!img)
return NS_ERROR_FAILURE;
UpdateGC();
// doesn't it seem like we should use more of the params here?
// img->Draw(*this, surface, sr.x, sr.y, sr.width, sr.height,
// pt.x + sr.x, pt.y + sr.y, sr.width, sr.height);
return mPrintContext->DrawImage(mGC, img, pt.x, pt.y, sr.width, sr.height);
}
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
NS_IMETHODIMP nsRenderingContextXp::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::DrawScaledImage()\n"));
nsRect dr;
dr = *aDestRect;

View File

@ -68,8 +68,7 @@ class nsRenderingContextXp : public nsRenderingContextXlib
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);

View File

@ -199,12 +199,11 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
nsCOMPtr<imgIContainer> imageCon;
mImageRequest->GetImage(getter_AddRefs(imageCon));
if (imageCon) {
nsRect innerArea(mPadding.left, mPadding.top,
nsRect innerArea(0, 0,
mRect.width - (mPadding.left + mPadding.right),
mRect.height - (mPadding.top + mPadding.bottom));
nsPoint p(innerArea.x, innerArea.y);
innerArea.x = innerArea.y = 0;
aRenderingContext.DrawImage(imageCon, &innerArea, &p);
nsRect dest(mPadding.left, mPadding.top, innerArea.width, innerArea.height);
aRenderingContext.DrawImage(imageCon, innerArea, dest);
return NS_OK;
}
}

View File

@ -1136,9 +1136,9 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
}
if (imgCon) {
// draw it
nsPoint p(inner.x, inner.y);
nsRect r(0,0,size,size);
aRenderingContext.DrawImage(imgCon, &r, &p);
nsRect source(0,0,size,size);
nsRect dest(inner.x,inner.y,size,size);
aRenderingContext.DrawImage(imgCon, source, dest);
iconUsed = PR_TRUE;
}
}
@ -1261,16 +1261,13 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
// Find the actual rect to be painted to in the rendering context
paintArea.IntersectRect(paintArea, aDirtyRect);
// Point to paint to
nsPoint p(paintArea.x, paintArea.y);
// Rect in the image to paint
nsRect r(paintArea.x - inner.x,
paintArea.y - inner.y + offsetY,
paintArea.width,
paintArea.height);
aRenderingContext.DrawImage(imgCon, &r, &p);
aRenderingContext.DrawImage(imgCon, r, paintArea);
} else {
// The computed size is the total size of all the continuations,
// including ourselves. Note that we're basically inverting
@ -1295,11 +1292,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
// Transform that to image coords
trans.TransformCoord(&r.x, &r.y, &r.width, &r.height);
// dest rect in our coords
nsRect d(paintArea.x, paintArea.y,
paintArea.width, paintArea.height);
aRenderingContext.DrawScaledImage(imgCon, &r, &d);
aRenderingContext.DrawImage(imgCon, r, paintArea);
}
paintOutline = PR_TRUE;
}

View File

@ -199,12 +199,11 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
nsCOMPtr<imgIContainer> imageCon;
mImageRequest->GetImage(getter_AddRefs(imageCon));
if (imageCon) {
nsRect innerArea(mPadding.left, mPadding.top,
nsRect innerArea(0, 0,
mRect.width - (mPadding.left + mPadding.right),
mRect.height - (mPadding.top + mPadding.bottom));
nsPoint p(innerArea.x, innerArea.y);
innerArea.x = innerArea.y = 0;
aRenderingContext.DrawImage(imageCon, &innerArea, &p);
nsRect dest(mPadding.left, mPadding.top, innerArea.width, innerArea.height);
aRenderingContext.DrawImage(imageCon, innerArea, dest);
return NS_OK;
}
}

View File

@ -1136,9 +1136,9 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
}
if (imgCon) {
// draw it
nsPoint p(inner.x, inner.y);
nsRect r(0,0,size,size);
aRenderingContext.DrawImage(imgCon, &r, &p);
nsRect source(0,0,size,size);
nsRect dest(inner.x,inner.y,size,size);
aRenderingContext.DrawImage(imgCon, source, dest);
iconUsed = PR_TRUE;
}
}
@ -1261,16 +1261,13 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
// Find the actual rect to be painted to in the rendering context
paintArea.IntersectRect(paintArea, aDirtyRect);
// Point to paint to
nsPoint p(paintArea.x, paintArea.y);
// Rect in the image to paint
nsRect r(paintArea.x - inner.x,
paintArea.y - inner.y + offsetY,
paintArea.width,
paintArea.height);
aRenderingContext.DrawImage(imgCon, &r, &p);
aRenderingContext.DrawImage(imgCon, r, paintArea);
} else {
// The computed size is the total size of all the continuations,
// including ourselves. Note that we're basically inverting
@ -1295,11 +1292,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
// Transform that to image coords
trans.TransformCoord(&r.x, &r.y, &r.width, &r.height);
// dest rect in our coords
nsRect d(paintArea.x, paintArea.y,
paintArea.width, paintArea.height);
aRenderingContext.DrawScaledImage(imgCon, &r, &d);
aRenderingContext.DrawImage(imgCon, r, paintArea);
}
paintOutline = PR_TRUE;
}

View File

@ -502,7 +502,7 @@ nsImageBoxFrame::PaintImage(nsIRenderingContext& aRenderingContext,
mImageSize.width == rect.width && mImageSize.height == rect.height;
if (sizeMatch) {
nsPoint p(rect.x, rect.y);
nsRect dest(rect);
if (hasSubRect)
rect = mSubRect;
@ -513,13 +513,13 @@ nsImageBoxFrame::PaintImage(nsIRenderingContext& aRenderingContext,
// XXXdwh do dirty rect intersection like the HTML image frame does,
// so that we don't always repaint the entire image!
aRenderingContext.DrawImage(imgCon, &rect, &p);
aRenderingContext.DrawImage(imgCon, rect, dest);
}
else {
nsRect src(0, 0, mImageSize.width, mImageSize.height);
if (hasSubRect)
src = mSubRect;
aRenderingContext.DrawScaledImage(imgCon, &src, &rect);
aRenderingContext.DrawImage(imgCon, src, rect);
}
}
}

View File

@ -2617,15 +2617,15 @@ nsTreeBodyFrame::PaintTwisty(PRInt32 aRowIndex,
PRBool useImageRegion = PR_TRUE;
GetImage(aRowIndex, aColumn, PR_TRUE, twistyContext, useImageRegion, getter_AddRefs(image));
if (image) {
nsPoint p(twistyRect.x, twistyRect.y);
nsRect r(twistyRect.x, twistyRect.y, imageSize.width, imageSize.height);
// Center the image. XXX Obey vertical-align style prop?
if (imageSize.height < twistyRect.height) {
p.y += (twistyRect.height - imageSize.height)/2;
r.y += (twistyRect.height - imageSize.height)/2;
}
// Paint the image.
aRenderingContext.DrawImage(image, &imageSize, &p);
aRenderingContext.DrawImage(image, imageSize, r);
}
}
}
@ -2686,21 +2686,21 @@ nsTreeBodyFrame::PaintImage(PRInt32 aRowIndex,
imageRect.Deflate(bp);
imageSize.Deflate(bp);
nsPoint p(imageRect.x, imageRect.y);
nsRect r(imageRect.x, imageRect.y, imageSize.width, imageSize.height);
// Center the image. XXX Obey vertical-align style prop?
if (imageSize.height < imageRect.height) {
p.y += (imageRect.height - imageSize.height)/2;
r.y += (imageRect.height - imageSize.height)/2;
}
// For cyclers, we also want to center the image in the column.
if (aColumn->IsCycler() && imageSize.width < imageRect.width) {
p.x += (imageRect.width - imageSize.width)/2;
r.x += (imageRect.width - imageSize.width)/2;
}
// Paint the image.
aRenderingContext.DrawImage(image, &imageSize, &p);
aRenderingContext.DrawImage(image, imageSize, r);
}
}
@ -2957,18 +2957,18 @@ nsTreeBodyFrame::PaintCheckbox(PRInt32 aRowIndex,
PRBool useImageRegion = PR_TRUE;
GetImage(aRowIndex, aColumn, PR_TRUE, checkboxContext, useImageRegion, getter_AddRefs(image));
if (image) {
nsPoint p(checkboxRect.x, checkboxRect.y);
nsRect r(checkboxRect.x, checkboxRect.y, imageSize.width, imageSize.height);
if (imageSize.height < checkboxRect.height) {
p.y += (checkboxRect.height - imageSize.height)/2;
r.y += (checkboxRect.height - imageSize.height)/2;
}
if (imageSize.width < checkboxRect.width) {
p.x += (checkboxRect.width - imageSize.width)/2;
r.x += (checkboxRect.width - imageSize.width)/2;
}
// Paint the image.
aRenderingContext.DrawImage(image, &imageSize, &p);
aRenderingContext.DrawImage(image, imageSize, r);
}
}