| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 while (sourceElement.firstChild) | 288 while (sourceElement.firstChild) |
| 289 sourceElement.removeChild(sourceElement.firstChild); | 289 sourceElement.removeChild(sourceElement.firstChild); |
| 290 for (let i = 0; i < subscriptions.length; i++) | 290 for (let i = 0; i < subscriptions.length; i++) |
| 291 setMultilineContent(sourceElement, subscriptions[i].title, true); | 291 setMultilineContent(sourceElement, subscriptions[i].title, true); |
| 292 } | 292 } |
| 293 } | 293 } |
| 294 | 294 |
| 295 var showPreview = Prefs.previewimages && !("tooltip" in item); | 295 var showPreview = Prefs.previewimages && !("tooltip" in item); |
| 296 showPreview = showPreview && item.typeDescr == "IMAGE"; | 296 showPreview = showPreview && item.typeDescr == "IMAGE"; |
| 297 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil
ter instanceof WhitelistFilter); | 297 showPreview = showPreview && (!item.filter || item.filter.disabled || item.fil
ter instanceof WhitelistFilter); |
| 298 if (showPreview) { | 298 if (showPreview) |
| 299 { |
| 299 // Check whether image is in cache (stolen from ImgLikeOpera) | 300 // Check whether image is in cache (stolen from ImgLikeOpera) |
| 300 if (!cacheSession) { | 301 if (!cacheSession) |
| 302 { |
| 301 var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(C
i.nsICacheService); | 303 var cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(C
i.nsICacheService); |
| 302 cacheSession = cacheService.createSession("HTTP", Ci.nsICache.STORE_ANYWHE
RE, true); | 304 cacheSession = cacheService.createSession("HTTP", Ci.nsICache.STORE_ANYWHE
RE, true); |
| 303 } | 305 } |
| 304 | 306 |
| 305 try { | 307 let cacheListener = |
| 306 var descriptor = cacheSession.openCacheEntry(item.location, Ci.nsICache.AC
CESS_READ, false); | 308 { |
| 307 descriptor.close(); | 309 onCacheEntryAvailable: function(descriptor, accessGranted, status) |
| 310 { |
| 311 if (!descriptor) |
| 312 return; |
| 313 |
| 314 descriptor.close(); |
| 315 // Show preview here since this is asynchronous now |
| 316 // and we have a valid descriptor |
| 317 E("tooltipPreview").setAttribute("src", item.location); |
| 318 E("tooltipPreviewBox").hidden = false; |
| 319 }, |
| 320 onCacheEntryDoomed: function(status) |
| 321 { |
| 322 } |
| 323 }; |
| 324 try |
| 325 { |
| 326 cacheSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, c
acheListener); |
| 308 } | 327 } |
| 309 catch (e) { | 328 catch (e) |
| 310 showPreview = false; | 329 { |
| 330 Cu.reportError(e); |
| 311 } | 331 } |
| 312 } | 332 } |
| 313 | 333 |
| 314 if (showPreview) { | 334 E("tooltipPreviewBox").hidden = true; |
| 315 E("tooltipPreviewBox").hidden = false; | |
| 316 E("tooltipPreview").setAttribute("src", ""); | |
| 317 E("tooltipPreview").setAttribute("src", item.location); | |
| 318 } | |
| 319 else | |
| 320 E("tooltipPreviewBox").hidden = true; | |
| 321 } | 335 } |
| 322 | 336 |
| 323 const visual = { | 337 const visual = { |
| 324 OTHER: true, | 338 OTHER: true, |
| 325 IMAGE: true, | 339 IMAGE: true, |
| 326 SUBDOCUMENT: true | 340 SUBDOCUMENT: true |
| 327 } | 341 } |
| 328 | 342 |
| 329 /** | 343 /** |
| 330 * Updates context menu before it is shown. | 344 * Updates context menu before it is shown. |
| (...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1223 return {tooltip: this.itemsDummyTooltip}; | 1237 return {tooltip: this.itemsDummyTooltip}; |
| 1224 }, | 1238 }, |
| 1225 | 1239 |
| 1226 invalidateItem: function(item) | 1240 invalidateItem: function(item) |
| 1227 { | 1241 { |
| 1228 let row = this.data.indexOf(item); | 1242 let row = this.data.indexOf(item); |
| 1229 if (row >= 0) | 1243 if (row >= 0) |
| 1230 this.boxObject.invalidateRow(row); | 1244 this.boxObject.invalidateRow(row); |
| 1231 } | 1245 } |
| 1232 } | 1246 } |
| OLD | NEW |