Loading and Broken image icons will no longer be drawn if the image size is smaller than the icon size. This fixes a problem where garbage was being left on the screen after the image loaded, because the Linux RenderingContext does not corectly clip image drawing. b=109418, r=pavlov, sr=blizzard, a=blizard on behalf of drivers

This commit is contained in:
attinasi%netscape.com 2002-01-18 22:17:12 +00:00
Родитель 56bf1626c2
Коммит f3438d8f49
2 изменённых файлов: 28 добавлений и 0 удалений

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

@ -1117,6 +1117,17 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
return;
}
// check if the size of the (deflated) rect is big enough to show the icon
// - if not, then just bail, leaving the border rect by itself
// NOTE: setting the clip (below) should be enough, but there is a bug in the Linux
// rendering context that images are not clipped when a clip rect is set (bugzilla bug 78497)
// and also this will be slightly more efficient since we will not try to render any icons
// or ALT text into the rect.
if (inner.width < NSIntPixelsToTwips(ICON_SIZE, p2t) ||
inner.height < NSIntPixelsToTwips(ICON_SIZE, p2t)) {
return;
}
// Clip so we don't render outside the inner rect
PRBool clipState;
aRenderingContext.PushState();
@ -2095,6 +2106,8 @@ PRBool nsImageFrame::HandleIconLoads(imgIRequest* aRequest, PRBool aLoaded)
void nsImageFrame::InvalidateIcon(nsIPresContext *aPresContext)
{
// invalidate the inner area, where the icon lives
NS_ASSERTION(aPresContext, "null presContext in InvalidateIcon");
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
@ -2105,6 +2118,7 @@ void nsImageFrame::InvalidateIcon(nsIPresContext *aPresContext)
inner.y,
NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING, p2t),
NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING, p2t));
NS_ASSERTION(!rect.IsEmpty(), "icon rect cannot be empty!");
Invalidate(aPresContext, rect, PR_FALSE);
}

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

@ -1117,6 +1117,17 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
return;
}
// check if the size of the (deflated) rect is big enough to show the icon
// - if not, then just bail, leaving the border rect by itself
// NOTE: setting the clip (below) should be enough, but there is a bug in the Linux
// rendering context that images are not clipped when a clip rect is set (bugzilla bug 78497)
// and also this will be slightly more efficient since we will not try to render any icons
// or ALT text into the rect.
if (inner.width < NSIntPixelsToTwips(ICON_SIZE, p2t) ||
inner.height < NSIntPixelsToTwips(ICON_SIZE, p2t)) {
return;
}
// Clip so we don't render outside the inner rect
PRBool clipState;
aRenderingContext.PushState();
@ -2095,6 +2106,8 @@ PRBool nsImageFrame::HandleIconLoads(imgIRequest* aRequest, PRBool aLoaded)
void nsImageFrame::InvalidateIcon(nsIPresContext *aPresContext)
{
// invalidate the inner area, where the icon lives
NS_ASSERTION(aPresContext, "null presContext in InvalidateIcon");
float p2t;
aPresContext->GetScaledPixelsToTwips(&p2t);
@ -2105,6 +2118,7 @@ void nsImageFrame::InvalidateIcon(nsIPresContext *aPresContext)
inner.y,
NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING, p2t),
NSIntPixelsToTwips(ICON_SIZE+ICON_PADDING, p2t));
NS_ASSERTION(!rect.IsEmpty(), "icon rect cannot be empty!");
Invalidate(aPresContext, rect, PR_FALSE);
}