Bug 1008942. When a network request for an image finishes during paint suppression and the image doesn't have a frame don't start a decode. r=mats

Either the image won't get a frame, or it will get a frame very soon and that frame will check its own visibility and kick off a decode if needed.
This commit is contained in:
Timothy Nikkel 2014-06-25 23:45:08 -05:00
parent 909098e8b3
commit 66177c6cd0

View File

@ -240,15 +240,24 @@ nsImageLoadingContent::OnStopRequest(imgIRequest* aRequest,
if (shell && shell->IsVisible() &&
(!shell->DidInitialize() || shell->IsPaintingSuppressed())) {
// If we've gotten a frame and that frame has called FrameCreate and that
// frame has been reflowed then we know that it checked it's own visibility
// so we can trust our visible count and we don't start decode if we are not
// visible.
nsIFrame* f = GetOurPrimaryFrame();
if (!mFrameCreateCalled || !f || (f->GetStateBits() & NS_FRAME_FIRST_REFLOW) ||
mVisibleCount > 0 || shell->AssumeAllImagesVisible()) {
if (NS_SUCCEEDED(mCurrentRequest->StartDecoding())) {
startedDecoding = true;
// If we haven't gotten a frame yet either we aren't going to (so don't
// bother kicking off a decode), or we will get very soon on the next
// refresh driver tick when it flushes. And it will most likely be a
// specific image type frame (we only create generic (ie inline) type
// frames for images that don't have a size, and since we have all the data
// we should have the size) which will check its own visibility on its
// first reflow.
if (f) {
// If we've gotten a frame and that frame has called FrameCreate and that
// frame has been reflowed then we know that it checked it's own visibility
// so we can trust our visible count and we don't start decode if we are not
// visible.
if (!mFrameCreateCalled || (f->GetStateBits() & NS_FRAME_FIRST_REFLOW) ||
mVisibleCount > 0 || shell->AssumeAllImagesVisible()) {
if (NS_SUCCEEDED(mCurrentRequest->StartDecoding())) {
startedDecoding = true;
}
}
}
}