From a1bd2566188973199ef1b1cb8b2bea5f6752e7a7 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Tue, 2 Feb 2016 16:51:52 -0600 Subject: [PATCH] Bug 1238337. If the intrinsic size of the image hasn't changed then we don't need to do a new predictive image decode. r=mats nsImageFrame::OnSizeAvailable will update the intrinsic ratio and ask for a reflow. Then nsImageFrame::NotifyNewCurrentRequest will be called when the image is finished loading. It previously would do a predictive decode if the intrinsic size hadn't changed. This was a mistake in http://hg.mozilla.org/mozilla-central/rev/146f1bea4147 (bug 1151359). OnSizeAvailable has this structure: if (intrinsicSizeChanged && gotInitialReflow) { if (!sizeConstrained) { requestReflow(); } } NotifyNewCurrentRequest has this structure: if (gotInitialReflow) { if (!sizeConstrained && intrinsicSizeChanged) { requestReflow(); } } Bug 1151359 added a predictive decode in a new else branch to both inner if statements. The meaning of this is obviously quite different. --- layout/generic/nsImageFrame.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 7256a013b070..20e6f551283f 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -681,16 +681,18 @@ nsImageFrame::NotifyNewCurrentRequest(imgIRequest *aRequest, } if (mState & IMAGE_GOTINITIALREFLOW) { // do nothing if we haven't gotten the initial reflow yet - if (!(mState & IMAGE_SIZECONSTRAINED) && intrinsicSizeChanged) { - nsIPresShell *presShell = PresContext()->GetPresShell(); - if (presShell) { - presShell->FrameNeedsReflow(this, nsIPresShell::eStyleChange, - NS_FRAME_IS_DIRTY); + if (intrinsicSizeChanged) { + if (!(mState & IMAGE_SIZECONSTRAINED)) { + nsIPresShell *presShell = PresContext()->GetPresShell(); + if (presShell) { + presShell->FrameNeedsReflow(this, nsIPresShell::eStyleChange, + NS_FRAME_IS_DIRTY); + } + } else { + // We've already gotten the initial reflow, and our size hasn't changed, + // so we're ready to request a decode. + MaybeDecodeForPredictedSize(); } - } else { - // We've already gotten the initial reflow, and our size hasn't changed, - // so we're ready to request a decode. - MaybeDecodeForPredictedSize(); } // Update border+content to account for image change InvalidateFrame();