Invalidate the incremently loaded portion of an image instead of the entire image if the image is not tiled. bug 41134 r=rods@netscape.com sr=attinasi@netscape.com

This commit is contained in:
kmcclusk%netscape.com 2001-02-14 05:31:02 +00:00
Родитель 0397fb7a41
Коммит 43f2e98742
1 изменённых файлов: 43 добавлений и 17 удалений

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

@ -478,12 +478,14 @@ nsFrameImageLoader::Notify(nsIImageRequest *aImageRequest,
mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_IMAGE_READY; mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_IMAGE_READY;
// Convert the rect from pixels to twips // Convert the rect from pixels to twips
// Note the 1 pixel inflation of the damage rect
// to account for off by 1 pixel rounding errors.
mPresContext->GetScaledPixelsToTwips(&p2t); mPresContext->GetScaledPixelsToTwips(&p2t);
changeRect = (const nsRect*) aParam3; changeRect = (const nsRect*) aParam3;
damageRect.x = NSIntPixelsToTwips(changeRect->x, p2t); damageRect.x = NSIntPixelsToTwips(changeRect->x, p2t);
damageRect.y = NSIntPixelsToTwips(changeRect->y, p2t); damageRect.y = NSIntPixelsToTwips((changeRect->y - 1), p2t);
damageRect.width = NSIntPixelsToTwips(changeRect->width, p2t); damageRect.width = NSIntPixelsToTwips(changeRect->width, p2t);
damageRect.height = NSIntPixelsToTwips(changeRect->height, p2t); damageRect.height = NSIntPixelsToTwips((changeRect->height + 1), p2t);
DamageRepairFrames(&damageRect); DamageRepairFrames(&damageRect);
break; break;
@ -607,21 +609,45 @@ nsFrameImageLoader::DamageRepairFrames(const nsRect* aDamageRect)
frame->GetRect(bounds); frame->GetRect(bounds);
bounds.x = bounds.y = 0; bounds.x = bounds.y = 0;
// XXX We should tell the frame the damage area and let it invalidate // Invalidate the entire frame only if the frame has a tiled background
// itself. Add some API calls to nsIFrame to allow a caller to invalidate // image, otherwise just invalidate the intersection of the frame's bounds
// parts of the frame... // with the damaged rect.
frame->GetView(mPresContext, &view);
if (!view) { nsCOMPtr<nsIStyleContext> styleContext;
frame->GetOffsetFromView(mPresContext, offset, &view); frame->GetStyleContext(getter_AddRefs(styleContext));
bounds.x += offset.x; const nsStyleColor* color = (const nsStyleColor*)
bounds.y += offset.y; styleContext->GetStyleData(eStyleStruct_Color);
if ((color->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) ||
(color->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) ||
(color->mBackgroundRepeat == NS_STYLE_BG_REPEAT_OFF)) {
// The frame does not have a background image so we are free
// to invalidate only the intersection of the damage rect and
// the frame's bounds.
if (aDamageRect) {
bounds.IntersectRect(*aDamageRect, bounds);
}
} }
nsCOMPtr<nsIViewManager> vm = nsnull; if ((bounds.width > 0) && (bounds.height > 0)) {
nsresult rv = NS_OK;
rv = view->GetViewManager(*getter_AddRefs(vm)); // XXX We should tell the frame the damage area and let it invalidate
if (NS_SUCCEEDED(rv) && vm) { // itself. Add some API calls to nsIFrame to allow a caller to invalidate
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC); // parts of the frame...
frame->GetView(mPresContext, &view);
if (!view) {
frame->GetOffsetFromView(mPresContext, offset, &view);
bounds.x += offset.x;
bounds.y += offset.y;
}
nsCOMPtr<nsIViewManager> vm = nsnull;
nsresult rv = NS_OK;
rv = view->GetViewManager(*getter_AddRefs(vm));
if (NS_SUCCEEDED(rv) && vm) {
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC);
}
} }
} }
} }