Index: chrome/content/ui/sidebar.js |
=================================================================== |
--- a/chrome/content/ui/sidebar.js |
+++ b/chrome/content/ui/sidebar.js |
@@ -295,26 +295,44 @@ |
var showPreview = Prefs.previewimages && !("tooltip" in item); |
showPreview = showPreview && item.typeDescr == "IMAGE"; |
showPreview = showPreview && (!item.filter || item.filter.disabled || item.filter instanceof WhitelistFilter); |
- if (showPreview) { |
+ if (showPreview) |
+ { |
// Check whether image is in cache (stolen from ImgLikeOpera) |
- if (!cacheSession) { |
+ if (!cacheSession) |
+ { |
var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService); |
cacheSession = cacheService.createSession("HTTP", Ci.nsICache.STORE_ANYWHERE, true); |
} |
- try { |
- var descriptor = cacheSession.openCacheEntry(item.location, Ci.nsICache.ACCESS_READ, false); |
- descriptor.close(); |
+ let cacheListener = { |
Wladimir Palant
2013/11/26 11:35:31
Style nit: this bracket should be on the next line
Thomas Greiner
2013/11/29 14:35:44
Done.
|
+ onCacheEntryAvailable: function(descriptor, accessGranted, status) |
+ { |
+ if (!descriptor) |
+ return; |
+ |
+ descriptor.close(); |
+ // Show preview here since this is asynchronous now |
+ // and we have a valid descriptor |
+ E("tooltipPreview").setAttribute("src", item.location); |
+ }, |
+ onCacheEntryDoomed: function(status) |
+ { |
+ } |
+ }; |
+ try |
+ { |
+ cacheSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, cacheListener); |
} |
- catch (e) { |
+ catch (e) |
+ { |
showPreview = false; |
Wladimir Palant
2013/11/26 11:35:31
This should normally never happen, please add Cu.r
Thomas Greiner
2013/11/29 14:35:44
Done.
|
} |
} |
- if (showPreview) { |
+ if (showPreview) |
+ { |
E("tooltipPreviewBox").hidden = false; |
E("tooltipPreview").setAttribute("src", ""); |
- E("tooltipPreview").setAttribute("src", item.location); |
} |
else |
E("tooltipPreviewBox").hidden = true; |
Wladimir Palant
2013/11/26 11:35:31
We should not show the preview box at all if we ar
Thomas Greiner
2013/11/29 14:35:44
Done.
|