Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: chrome/content/ui/sidebar.js

Issue 6349471881363456: Fixed: Topic 12380 - No image preview in list of blockable items (Closed)
Patch Set: Created Nov. 14, 2013, 11:13 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 = {
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.
306 var descriptor = cacheSession.openCacheEntry(item.location, Ci.nsICache.AC CESS_READ, false); 308 onCacheEntryAvailable: function(descriptor, accessGranted, status)
307 descriptor.close(); 309 {
310 if (!descriptor)
311 return;
312
313 descriptor.close();
314 // Show preview here since this is asynchronous now
315 // and we have a valid descriptor
316 E("tooltipPreview").setAttribute("src", item.location);
317 },
318 onCacheEntryDoomed: function(status)
319 {
320 }
321 };
322 try
323 {
324 cacheSession.asyncOpenCacheEntry(item.location, Ci.nsICache.ACCESS_READ, c acheListener);
308 } 325 }
309 catch (e) { 326 catch (e)
327 {
310 showPreview = false; 328 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.
311 } 329 }
312 } 330 }
313 331
314 if (showPreview) { 332 if (showPreview)
333 {
315 E("tooltipPreviewBox").hidden = false; 334 E("tooltipPreviewBox").hidden = false;
316 E("tooltipPreview").setAttribute("src", ""); 335 E("tooltipPreview").setAttribute("src", "");
317 E("tooltipPreview").setAttribute("src", item.location);
318 } 336 }
319 else 337 else
320 E("tooltipPreviewBox").hidden = true; 338 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.
321 } 339 }
322 340
323 const visual = { 341 const visual = {
324 OTHER: true, 342 OTHER: true,
325 IMAGE: true, 343 IMAGE: true,
326 SUBDOCUMENT: true 344 SUBDOCUMENT: true
327 } 345 }
328 346
329 /** 347 /**
330 * Updates context menu before it is shown. 348 * Updates context menu before it is shown.
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 return {tooltip: this.itemsDummyTooltip}; 1241 return {tooltip: this.itemsDummyTooltip};
1224 }, 1242 },
1225 1243
1226 invalidateItem: function(item) 1244 invalidateItem: function(item)
1227 { 1245 {
1228 let row = this.data.indexOf(item); 1246 let row = this.data.indexOf(item);
1229 if (row >= 0) 1247 if (row >= 0)
1230 this.boxObject.invalidateRow(row); 1248 this.boxObject.invalidateRow(row);
1231 } 1249 }
1232 } 1250 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld