Bug 1128225 (Part 2) - Propagate the imgIContainer::Draw result through the nsLayoutUtils::Draw*Image functions. r=tn

This commit is contained in:
Seth Fowler 2015-02-04 13:50:56 -08:00
Родитель a79546917f
Коммит 1624013327
2 изменённых файлов: 58 добавлений и 50 удалений

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

@ -5872,7 +5872,7 @@ ComputeSnappedImageDrawingParameters(gfxContext* aCtx,
}
static nsresult
static DrawResult
DrawImageInternal(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
@ -5900,8 +5900,9 @@ DrawImageInternal(gfxContext& aContext,
aFill, aAnchor, aDirty, aImage,
aGraphicsFilter, aImageFlags);
if (!params.shouldDraw)
return NS_OK;
if (!params.shouldDraw) {
return DrawResult::SUCCESS;
}
gfxContextMatrixAutoSaveRestore contextMatrixRestorer(&aContext);
aContext.SetMatrix(params.imageSpaceToDeviceSpace);
@ -5912,13 +5913,12 @@ DrawImageInternal(gfxContext& aContext,
svgContext = Some(SVGImageContext(params.svgViewportSize, Nothing()));
}
aImage->Draw(&aContext, params.size, params.region, imgIContainer::FRAME_CURRENT,
aGraphicsFilter, svgContext, aImageFlags);
return NS_OK;
return aImage->Draw(&aContext, params.size, params.region,
imgIContainer::FRAME_CURRENT, aGraphicsFilter,
svgContext, aImageFlags);
}
/* static */ nsresult
/* static */ DrawResult
nsLayoutUtils::DrawSingleUnscaledImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
@ -5931,7 +5931,10 @@ nsLayoutUtils::DrawSingleUnscaledImage(gfxContext& aContext,
nsIntSize imageSize;
aImage->GetWidth(&imageSize.width);
aImage->GetHeight(&imageSize.height);
NS_ENSURE_TRUE(imageSize.width > 0 && imageSize.height > 0, NS_ERROR_FAILURE);
if (imageSize.width < 1 || imageSize.height < 1) {
NS_WARNING("Image width or height is non-positive");
return DrawResult::TEMPORARY_ERROR;
}
nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
nsSize size(imageSize.width*appUnitsPerCSSPixel,
@ -5956,7 +5959,7 @@ nsLayoutUtils::DrawSingleUnscaledImage(gfxContext& aContext,
nullptr, aImageFlags);
}
/* static */ nsresult
/* static */ DrawResult
nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
@ -5970,7 +5973,11 @@ nsLayoutUtils::DrawSingleImage(gfxContext& aContext,
{
nscoord appUnitsPerCSSPixel = nsDeviceContext::AppUnitsPerCSSPixel();
nsIntSize pixelImageSize(ComputeSizeForDrawingWithFallback(aImage, aDest.Size()));
NS_ENSURE_TRUE(pixelImageSize.width > 0 && pixelImageSize.height > 0, NS_ERROR_FAILURE);
if (pixelImageSize.width < 1 || pixelImageSize.height < 1) {
NS_WARNING("Image width or height is non-positive");
return DrawResult::TEMPORARY_ERROR;
}
nsSize imageSize(pixelImageSize.width * appUnitsPerCSSPixel,
pixelImageSize.height * appUnitsPerCSSPixel);
@ -6069,7 +6076,7 @@ nsLayoutUtils::ComputeSizeForDrawingWithFallback(imgIContainer* aImage,
return imageSize;
}
/* static */ nsresult
/* static */ DrawResult
nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
@ -6095,7 +6102,7 @@ nsLayoutUtils::DrawBackgroundImage(gfxContext& aContext,
aDirty, &svgContext, aImageFlags);
}
/* static */ nsresult
/* static */ DrawResult
nsLayoutUtils::DrawImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,

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

@ -127,6 +127,7 @@ class nsLayoutUtils
typedef mozilla::gfx::Matrix4x4 Matrix4x4;
typedef mozilla::gfx::RectCornerRadii RectCornerRadii;
typedef mozilla::gfx::StrokeOptions StrokeOptions;
typedef mozilla::image::DrawResult DrawResult;
public:
typedef mozilla::layers::FrameMetrics FrameMetrics;
@ -1657,16 +1658,16 @@ public:
* @param aDirty Pixels outside this area may be skipped.
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
*/
static nsresult DrawBackgroundImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
const nsIntSize& aImageSize,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aFill,
const nsPoint& aAnchor,
const nsRect& aDirty,
uint32_t aImageFlags);
static DrawResult DrawBackgroundImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
const nsIntSize& aImageSize,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aFill,
const nsPoint& aAnchor,
const nsRect& aDirty,
uint32_t aImageFlags);
/**
* Draw an image.
@ -1683,15 +1684,15 @@ public:
* @param aDirty Pixels outside this area may be skipped.
* @param aImageFlags Image flags of the imgIContainer::FLAG_* variety
*/
static nsresult DrawImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aFill,
const nsPoint& aAnchor,
const nsRect& aDirty,
uint32_t aImageFlags);
static DrawResult DrawImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aFill,
const nsPoint& aAnchor,
const nsRect& aDirty,
uint32_t aImageFlags);
static inline void InitDashPattern(StrokeOptions& aStrokeOptions,
uint8_t aBorderStyle) {
@ -1737,14 +1738,14 @@ public:
* in appunits. For best results it should
* be aligned with image pixels.
*/
static nsresult DrawSingleUnscaledImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
GraphicsFilter aGraphicsFilter,
const nsPoint& aDest,
const nsRect* aDirty,
uint32_t aImageFlags,
const nsRect* aSourceArea = nullptr);
static DrawResult DrawSingleUnscaledImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
GraphicsFilter aGraphicsFilter,
const nsPoint& aDest,
const nsRect* aDirty,
uint32_t aImageFlags,
const nsRect* aSourceArea = nullptr);
/**
* Draw a whole image without tiling.
@ -1768,16 +1769,16 @@ public:
* in appunits. For best results it should
* be aligned with image pixels.
*/
static nsresult DrawSingleImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aDirty,
const mozilla::SVGImageContext* aSVGContext,
uint32_t aImageFlags,
const nsPoint* aAnchorPoint = nullptr,
const nsRect* aSourceArea = nullptr);
static DrawResult DrawSingleImage(gfxContext& aContext,
nsPresContext* aPresContext,
imgIContainer* aImage,
GraphicsFilter aGraphicsFilter,
const nsRect& aDest,
const nsRect& aDirty,
const mozilla::SVGImageContext* aSVGContext,
uint32_t aImageFlags,
const nsPoint* aAnchorPoint = nullptr,
const nsRect* aSourceArea = nullptr);
/**
* Given an imgIContainer, this method attempts to obtain an intrinsic