Bug 1351015 - Not assuming nsStyleImage::ComputeActualCropRect always return true. r=heycam
nsStyleImage::ComputeActualCropRect may return false under 4 conditions 1. mType is not eStyleImageType_Image. This function is design to be used when mType is eStyleImageType_Image. Replace this 'if' check by MOZ_ASSERT. 2. nsStyleImage::GetImageData() returns nullptr This function will return true if this image refers to a local-ref resource. 3. GetImage returns failure or does not return a valid imgIContainer. It's possible. Please refers to the comment in imgReqestProxy::GetImage at [1]. 4. imageSize is empty It's possible too. By giving a malformed image to a style image, we will hit this condition. And this is right what we met in this bug. Since ComputeActualCropRect may actaully return false, we should remove the NS_ASSERTION that assume it will always return true. [1] https://hg.mozilla.org/mozilla-central/file/7f1f1559cd8d/image/imgRequestProxy.cpp#l513 MozReview-Commit-ID: KHTFQJjiLtT
This commit is contained in:
@@ -148,7 +148,6 @@ nsImageRenderer::PrepareImage()
|
||||
bool isEntireImage;
|
||||
bool success =
|
||||
mImage->ComputeActualCropRect(actualCropRect, &isEntireImage);
|
||||
NS_ASSERTION(success, "ComputeActualCropRect() should not fail here");
|
||||
if (!success || actualCropRect.IsEmpty()) {
|
||||
// The cropped image has zero size
|
||||
mPrepareResult = DrawResult::BAD_IMAGE;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
== background-common-usage-pixel.html background-common-usage-pixel.html
|
||||
== background-draw-nothing-empty-rect.html background-draw-nothing-empty-rect.html
|
||||
== background-draw-nothing-invalid-syntax.html background-draw-nothing-invalid-syntax.html
|
||||
asserts(0-8) == background-draw-nothing-malformed-images.html background-draw-nothing-malformed-images.html
|
||||
== background-draw-nothing-malformed-images.html background-draw-nothing-malformed-images.html
|
||||
== background-monster-rect.html background-monster-rect.html
|
||||
== background-over-size-rect.html background-over-size-rect.html
|
||||
fails == background-test-parser.html background-test-parser.html
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
== background-common-usage-pixel.html background-common-usage-ref.html
|
||||
== background-draw-nothing-empty-rect.html background-draw-nothing-ref.html
|
||||
== background-draw-nothing-invalid-syntax.html background-draw-nothing-ref.html
|
||||
asserts(0-6) == background-draw-nothing-malformed-images.html background-draw-nothing-ref.html # Bug 576419
|
||||
== background-draw-nothing-malformed-images.html background-draw-nothing-ref.html
|
||||
== background-monster-rect.html background-monster-rect-ref.html
|
||||
== background-over-size-rect.html background-over-size-rect-ref.html
|
||||
== background-test-parser.html background-test-parser-ref.html
|
||||
|
||||
@@ -2338,9 +2338,9 @@ bool
|
||||
nsStyleImage::ComputeActualCropRect(nsIntRect& aActualCropRect,
|
||||
bool* aIsEntireImage) const
|
||||
{
|
||||
if (mType != eStyleImageType_Image) {
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(mType == eStyleImageType_Image,
|
||||
"This function is designed to be used only when mType"
|
||||
"is eStyleImageType_Image.");
|
||||
|
||||
imgRequestProxy* req = GetImageData();
|
||||
if (!req) {
|
||||
@@ -2421,9 +2421,7 @@ nsStyleImage::IsOpaque() const
|
||||
// Must make sure if mCropRect contains at least a pixel.
|
||||
// XXX Is this optimization worth it? Maybe I should just return false.
|
||||
nsIntRect actualCropRect;
|
||||
bool rv = ComputeActualCropRect(actualCropRect);
|
||||
NS_ASSERTION(rv, "ComputeActualCropRect() can not fail here");
|
||||
return rv && !actualCropRect.IsEmpty();
|
||||
return ComputeActualCropRect(actualCropRect) && !actualCropRect.IsEmpty();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user