зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1209739 - Make nsImageRenderer::PrepareImage() fail unless an image has STATUS_LOAD_COMPLETE. r=tn
This commit is contained in:
Родитель
93c62cd986
Коммит
d06321a00c
|
@ -4619,6 +4619,40 @@ nsImageRenderer::~nsImageRenderer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
ShouldTreatAsCompleteDueToSyncDecode(const nsStyleImage* aImage,
|
||||||
|
uint32_t aFlags)
|
||||||
|
{
|
||||||
|
if (!(aFlags & nsImageRenderer::FLAG_SYNC_DECODE_IMAGES)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aImage->GetType() != eStyleImageType_Image) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t status = 0;
|
||||||
|
if (NS_FAILED(aImage->GetImageData()->GetImageStatus(&status))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status & imgIRequest::STATUS_ERROR) {
|
||||||
|
// The image is "complete" since it's a corrupt image. If we created an
|
||||||
|
// imgIContainer at all, return true.
|
||||||
|
nsCOMPtr<imgIContainer> image;
|
||||||
|
aImage->GetImageData()->GetImage(getter_AddRefs(image));
|
||||||
|
return bool(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(status & imgIRequest::STATUS_LOAD_COMPLETE)) {
|
||||||
|
// We must have loaded all of the image's data and the size must be
|
||||||
|
// available, or else sync decoding won't be able to decode the image.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsImageRenderer::PrepareImage()
|
nsImageRenderer::PrepareImage()
|
||||||
{
|
{
|
||||||
|
@ -4628,24 +4662,19 @@ nsImageRenderer::PrepareImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mImage->IsComplete()) {
|
if (!mImage->IsComplete()) {
|
||||||
// Make sure the image is actually decoding
|
// Make sure the image is actually decoding.
|
||||||
mImage->StartDecoding();
|
mImage->StartDecoding();
|
||||||
|
|
||||||
// check again to see if we finished
|
// Check again to see if we finished.
|
||||||
if (!mImage->IsComplete()) {
|
|
||||||
// We cannot prepare the image for rendering if it is not fully loaded.
|
// We cannot prepare the image for rendering if it is not fully loaded.
|
||||||
//
|
// Special case: If we requested a sync decode and the image has loaded, push
|
||||||
// Special case: If we requested a sync decode and we have an image, push
|
// on through because the Draw() will do a sync decode then.
|
||||||
// on through because the Draw() will do a sync decode then
|
if (!mImage->IsComplete() &&
|
||||||
nsCOMPtr<imgIContainer> img;
|
!ShouldTreatAsCompleteDueToSyncDecode(mImage, mFlags)) {
|
||||||
if (!((mFlags & FLAG_SYNC_DECODE_IMAGES) &&
|
|
||||||
(mType == eStyleImageType_Image) &&
|
|
||||||
(NS_SUCCEEDED(mImage->GetImageData()->GetImage(getter_AddRefs(img)))))) {
|
|
||||||
mPrepareResult = DrawResult::NOT_READY;
|
mPrepareResult = DrawResult::NOT_READY;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case eStyleImageType_Image:
|
case eStyleImageType_Image:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче