Bug 1106252 - Make nsImageFrame's icon loading code more robust. r=tn
authorSeth Fowler <seth@mozilla.com>
Wed, 10 Dec 2014 18:42:37 -0800
changeset 219234 49a918ec025fba6c0fcfa83b404a10f2dd18b310
parent 219233 81bdd9d3aa258269fbc734f741322712951463a6
child 219235 af3dbca127d1e4f1acd54a3f6cec42eeea13b328
push id10368
push userkwierso@gmail.com
push dateFri, 12 Dec 2014 01:38:39 +0000
treeherderfx-team@5288b15d22de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1106252
milestone37.0a1
Bug 1106252 - Make nsImageFrame's icon loading code more robust. r=tn
layout/generic/nsImageFrame.cpp
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1260,26 +1260,26 @@ nsImageFrame::DisplayAltFeedback(nsRende
       mDisplayingIcon = true;
     }
 
 
     // If the icon in question is loaded and decoded, draw it
     uint32_t imageStatus = 0;
     if (aRequest)
       aRequest->GetImageStatus(&imageStatus);
-    if (imageStatus & imgIRequest::STATUS_FRAME_COMPLETE) {
+    if (imageStatus & imgIRequest::STATUS_LOAD_COMPLETE) {
       nsCOMPtr<imgIContainer> imgCon;
       aRequest->GetImage(getter_AddRefs(imgCon));
-      NS_ABORT_IF_FALSE(imgCon, "Frame Complete, but no image container?");
+      MOZ_ASSERT(imgCon, "Load complete, but no image container?");
       nsRect dest((vis->mDirection == NS_STYLE_DIRECTION_RTL) ?
                   inner.XMost() - size : inner.x,
                   inner.y, size, size);
       nsLayoutUtils::DrawSingleImage(*gfx, PresContext(), imgCon,
         nsLayoutUtils::GetGraphicsFilterForFrame(this), dest, aDirtyRect,
-        nullptr, imgIContainer::FLAG_NONE);
+        nullptr, imgIContainer::FLAG_SYNC_DECODE);
       iconUsed = true;
     }
 
     // if we could not draw the icon, flag that we're waiting for it and
     // just draw some graffiti in the mean time
     if (!iconUsed) {
       ColorPattern color(ToDeviceColor(Color(1.f, 0.f, 0.f, 1.f)));
 
@@ -2084,20 +2084,26 @@ nsresult nsImageFrame::LoadIcons(nsPresC
   nsresult rv;
   // create a loader and load the images
   rv = LoadIcon(loadingSrc,
                 aPresContext,
                 getter_AddRefs(gIconLoad->mLoadingImage));
   if (NS_FAILED(rv)) {
     return rv;
   }
+  gIconLoad->mLoadingImage->RequestDecode();
 
   rv = LoadIcon(brokenSrc,
                 aPresContext,
                 getter_AddRefs(gIconLoad->mBrokenImage));
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+  gIconLoad->mBrokenImage->RequestDecode();
+
   return rv;
 }
 
 NS_IMPL_ISUPPORTS(nsImageFrame::IconLoad, nsIObserver,
                   imgINotificationObserver)
 
 static const char* kIconLoadPrefs[] = {
   "browser.display.force_inline_alttext",