Don't bother painting a selection into an empty rect. Avoid using an invalid surface for painting ops. b=380611 r+sr=vladimir

This commit is contained in:
mats.palmgren@bredband.net 2007-05-17 03:14:35 -07:00
Родитель ed4675a9db
Коммит 45266392c0
2 изменённых файлов: 11 добавлений и 2 удалений

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

@ -4891,7 +4891,7 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
nsRect* aScreenRect)
{
nsPresContext* pc = GetPresContext();
if (!pc)
if (!pc || aArea.width == 0 || aArea.height == 0)
return nsnull;
nsIDeviceContext* deviceContext = pc->DeviceContext();
@ -4940,8 +4940,10 @@ PresShell::PaintRangePaintInfo(nsTArray<nsAutoPtr<RangePaintInfo> >* aItems,
gfxImageSurface* surface =
new gfxImageSurface(gfxIntSize(pixelArea.width, pixelArea.height),
gfxImageSurface::ImageFormatARGB32);
if (!surface)
if (!surface || surface->CairoStatus()) {
delete surface;
return nsnull;
}
// clear the image
gfxContext context(surface);
@ -5066,6 +5068,8 @@ PresShell::RenderSelection(nsISelection* aSelection,
// to allocate a surface area
PRInt32 numRanges;
aSelection->GetRangeCount(&numRanges);
NS_ASSERTION(numRanges > 0, "RenderSelection called with no selection");
for (PRInt32 r = 0; r < numRanges; r++)
{
nsCOMPtr<nsIDOMRange> range;

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

@ -90,6 +90,11 @@ nsImageToPixbuf::ImageToPixbuf(nsIImage* aImage)
GdkPixbuf*
nsImageToPixbuf::SurfaceToPixbuf(gfxASurface* aSurface, PRInt32 aWidth, PRInt32 aHeight)
{
if (aSurface->CairoStatus()) {
NS_ERROR("invalid surface");
return nsnull;
}
nsRefPtr<gfxImageSurface> imgSurface;
if (aSurface->GetType() == gfxASurface::SurfaceTypeImage) {
imgSurface = NS_STATIC_CAST(gfxImageSurface*,