Bug 1312770 - Part 3, increase loading priority for images that are visible in viewport. r?tnikkel
MozReview-Commit-ID: EsKRyMzZCKc
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1783,16 +1783,24 @@ nsImageFrame::BuildDisplayList(nsDisplay
// decoded yet. And we are not going to ask the image to draw, so this
// may be the only chance to tell it that it should decode.
if (currentRequest) {
uint32_t status = 0;
currentRequest->GetImageStatus(&status);
if (!(status & imgIRequest::STATUS_DECODE_COMPLETE)) {
MaybeDecodeForPredictedSize();
}
+
+ // Increase loading priority if the image is ready to be displayed.
+ if (!(status & imgIRequest::STATUS_LOAD_COMPLETE) &&
+ !mBoostLoadingForDisplay) {
+ mBoostLoadingForDisplay = true;
+ currentRequest->ForceAdjustPriority(nsISupportsPriority::PRIORITY_HIGH);
+ }
+
}
} else {
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayImage(aBuilder, this, mImage, mPrevImage));
// If we were previously displaying an icon, we're not anymore
if (mDisplayingIcon) {
gIconLoad->RemoveIconObserver(this);
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -335,16 +335,19 @@ private:
mozilla::IntrinsicSize mIntrinsicSize;
nsSize mIntrinsicRatio;
bool mDisplayingIcon;
bool mFirstFrameComplete;
bool mReflowCallbackPosted;
bool mForceSyncDecoding;
+ // True if image has increased loading priority for rendering
+ bool mBoostLoadingForDisplay = false;
+
static nsIIOService* sIOService;
/* loading / broken image icon support */
// XXXbz this should be handled by the prescontext, I think; that
// way we would have a single iconload per mozilla session instead
// of one per document...