Bug 799335. Fix unintenional image flash on tab switch. r=joe,dholbert

This was caused by bug 792199.

There are two parts to this fix:
1. Always decode during StartDecoding even if we already have a Decoder
(hopefully this is safe) This was a bug in the original patch.

2. After calling StartDecoding() we recheck if we're complete and abort if
we're not doing a SYNC_DECODE. Before this regression we would usually be done
decoding the image because of the decoding we did when we Locked all of the
images on tab switch.

--HG--
extra : rebase_source : 9db93075aad2f45c6cc70d27ef67468b4507642c
This commit is contained in:
Jeff Muizelaar 2012-10-12 16:04:32 -04:00
Родитель 89f298eb02
Коммит 8b8ae578b1
2 изменённых файлов: 24 добавлений и 12 удалений

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

@ -2552,9 +2552,15 @@ RasterImage::RequestDecodeCore(RequestDecodeType aDecodeType)
if (!StoringSourceData())
return NS_OK;
// If we've already got a full decoder running, we have nothing to do
if (mDecoder && !mDecoder->IsSizeDecode())
// If we've already got a full decoder running, we'll spend a bit of time
// decoding because the caller want's an image soon.
if (mDecoder && !mDecoder->IsSizeDecode()) {
if (!mDecoded && !mInDecoder && mHasSourceData && aDecodeType == SOMEWHAT_SYNCHRONOUS) {
SAMPLE_LABEL_PRINTF("RasterImage", "DecodeABitOf", "%s", GetURIString());
DecodeWorker::Singleton()->DecodeABitOf(this);
}
return NS_OK;
}
// mFinishing protects against the case when we enter RequestDecode from
// ShutdownDecoder -- in that case, we're done with the decode, we're just

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

@ -4014,19 +4014,25 @@ nsImageRenderer::~nsImageRenderer()
bool
nsImageRenderer::PrepareImage()
{
if (mImage->IsEmpty() || !mImage->IsComplete()) {
if (mImage->IsEmpty())
return false;
if (!mImage->IsComplete()) {
// Make sure the image is actually decoding
mImage->StartDecoding();
// We can not prepare the image for rendering if it is not fully loaded.
//
// Special case: If we requested a sync decode and we have an image, push
// on through
nsCOMPtr<imgIContainer> img;
if (!((mFlags & FLAG_SYNC_DECODE_IMAGES) &&
(mType == eStyleImageType_Image) &&
(NS_SUCCEEDED(mImage->GetImageData()->GetImage(getter_AddRefs(img))) && img)))
return false;
// check again to see if we finished
if (!mImage->IsComplete()) {
// We can not prepare the image for rendering if it is not fully loaded.
//
// 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
nsCOMPtr<imgIContainer> img;
if (!((mFlags & FLAG_SYNC_DECODE_IMAGES) &&
(mType == eStyleImageType_Image) &&
(NS_SUCCEEDED(mImage->GetImageData()->GetImage(getter_AddRefs(img))) && img)))
return false;
}
}
switch (mType) {