зеркало из https://github.com/mozilla/gecko-dev.git
Bug 739457 - Don't decode images when you load a link in a background tab. r=joe
This commit is contained in:
Родитель
f05ff8b40b
Коммит
74225dfdad
|
@ -314,42 +314,32 @@ nsImageLoadingContent::OnStopDecode(imgIRequest* aRequest,
|
||||||
mCurrentRequestNeedsResetAnimation = false;
|
mCurrentRequestNeedsResetAnimation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We just loaded all the data we're going to get. If we haven't done an
|
// We just loaded all the data we're going to get. If we're visible and
|
||||||
// initial paint, we want to make sure the image starts decoding for 2
|
// haven't done an initial paint (*), we want to make sure the image starts
|
||||||
// reasons:
|
// decoding immediately, for two reasons:
|
||||||
//
|
//
|
||||||
// 1) This image is sitting idle but might need to be decoded as soon as we
|
// 1) This image is sitting idle but might need to be decoded as soon as we
|
||||||
// start painting, in which case we've wasted time.
|
// start painting, in which case we've wasted time.
|
||||||
//
|
//
|
||||||
// 2) We want to block onload until all visible images are decoded. We do this
|
// 2) We want to block onload until all visible images are decoded. We do this
|
||||||
// by blocking onload until all in progress decodes get at least one frame
|
// by blocking onload until all in-progress decodes get at least one frame
|
||||||
// decoded. However, if all the data comes in while painting is suppressed
|
// decoded. However, if all the data comes in while painting is suppressed
|
||||||
// (ie, before the initial paint delay is finished), we fire onload without
|
// (ie, before the initial paint delay is finished), we fire onload without
|
||||||
// doing a paint first. This means that decode-on-draw images don't start
|
// doing a paint first. This means that decode-on-draw images don't start
|
||||||
// decoding, so we can't wait for them to finish. See bug 512435.
|
// decoding, so we can't wait for them to finish. See bug 512435.
|
||||||
|
//
|
||||||
|
// (*) IsPaintingSuppressed returns false if we haven't gotten the initial
|
||||||
|
// reflow yet, so we have to test !DidInitialReflow || IsPaintingSuppressed.
|
||||||
|
// It's possible for painting to be suppressed for reasons other than the
|
||||||
|
// initial paint delay (for example, being in the bfcache), but we probably
|
||||||
|
// aren't loading images in those situations.
|
||||||
|
|
||||||
// We can only do this if we have a presshell
|
|
||||||
nsIDocument* doc = GetOurDocument();
|
nsIDocument* doc = GetOurDocument();
|
||||||
nsIPresShell* shell = doc ? doc->GetShell() : nsnull;
|
nsIPresShell* shell = doc ? doc->GetShell() : nsnull;
|
||||||
if (shell) {
|
if (shell && shell->IsVisible() &&
|
||||||
// We need to figure out whether to kick off decoding
|
(!shell->DidInitialReflow() || shell->IsPaintingSuppressed())) {
|
||||||
bool doRequestDecode = false;
|
|
||||||
|
|
||||||
// If we haven't got the initial reflow yet, IsPaintingSuppressed actually
|
mCurrentRequest->RequestDecode();
|
||||||
// returns false
|
|
||||||
if (!shell->DidInitialReflow())
|
|
||||||
doRequestDecode = true;
|
|
||||||
|
|
||||||
// Figure out if painting is suppressed. Note that it's possible for painting
|
|
||||||
// to be suppressed for reasons other than the initial paint delay (for
|
|
||||||
// example - being in the bfcache), but we probably aren't loading images in
|
|
||||||
// those situations.
|
|
||||||
if (shell->IsPaintingSuppressed())
|
|
||||||
doRequestDecode = true;
|
|
||||||
|
|
||||||
// If we're requesting a decode, do it
|
|
||||||
if (doRequestDecode)
|
|
||||||
mCurrentRequest->RequestDecode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire the appropriate DOM event.
|
// Fire the appropriate DOM event.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче