Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 else | 251 else |
252 item = treeView.getItemAt(e.clientX, e.clientY); | 252 item = treeView.getItemAt(e.clientX, e.clientY); |
253 | 253 |
254 if (!item) | 254 if (!item) |
255 { | 255 { |
256 e.preventDefault(); | 256 e.preventDefault(); |
257 return; | 257 return; |
258 } | 258 } |
259 | 259 |
260 let filter = getFilter(item); | 260 let filter = getFilter(item); |
261 let size = ("tooltip" in item ? null : getItemSize(item)); | |
262 let subscriptions = (filter ? filter.subscriptions.filter(function(subscriptio n) { return !subscription.disabled; }) : []); | 261 let subscriptions = (filter ? filter.subscriptions.filter(function(subscriptio n) { return !subscription.disabled; }) : []); |
263 | 262 |
264 E("tooltipDummy").hidden = !("tooltip" in item); | 263 E("tooltipDummy").hidden = !("tooltip" in item); |
265 E("tooltipAddressRow").hidden = ("tooltip" in item); | 264 E("tooltipAddressRow").hidden = ("tooltip" in item); |
266 E("tooltipTypeRow").hidden = ("tooltip" in item); | 265 E("tooltipTypeRow").hidden = ("tooltip" in item); |
267 E("tooltipSizeRow").hidden = !size; | |
268 E("tooltipDocDomainRow").hidden = ("tooltip" in item || !item.docDomain); | 266 E("tooltipDocDomainRow").hidden = ("tooltip" in item || !item.docDomain); |
269 E("tooltipFilterRow").hidden = !filter; | 267 E("tooltipFilterRow").hidden = !filter; |
270 E("tooltipFilterSourceRow").hidden = !subscriptions.length; | 268 E("tooltipFilterSourceRow").hidden = !subscriptions.length; |
271 | 269 |
272 if ("tooltip" in item) | 270 if ("tooltip" in item) |
273 E("tooltipDummy").setAttribute("value", item.tooltip); | 271 E("tooltipDummy").setAttribute("value", item.tooltip); |
274 else | 272 else |
275 { | 273 { |
276 E("tooltipAddress").parentNode.hidden = (item.type == "ELEMHIDE"); | 274 E("tooltipAddress").parentNode.hidden = (item.type == "ELEMHIDE"); |
277 setMultilineContent(E("tooltipAddress"), item.location); | 275 setMultilineContent(E("tooltipAddress"), item.location); |
278 | 276 |
279 var type = localizedTypes.get(item.type); | 277 var type = localizedTypes.get(item.type); |
280 if (filter && filter instanceof WhitelistFilter) | 278 if (filter && filter instanceof WhitelistFilter) |
281 type += " " + E("tooltipType").getAttribute("whitelisted"); | 279 type += " " + E("tooltipType").getAttribute("whitelisted"); |
282 else if (filter && item.type != "ELEMHIDE") | 280 else if (filter && item.type != "ELEMHIDE") |
283 type += " " + E("tooltipType").getAttribute("filtered"); | 281 type += " " + E("tooltipType").getAttribute("filtered"); |
284 E("tooltipType").setAttribute("value", type); | 282 E("tooltipType").setAttribute("value", type); |
285 | 283 |
286 if (size) | |
287 E("tooltipSize").setAttribute("value", size.join(" x ")); | |
288 | |
289 E("tooltipDocDomain").setAttribute("value", item.docDomain + " " + (item.thi rdParty ? docDomainThirdParty : docDomainFirstParty)); | 284 E("tooltipDocDomain").setAttribute("value", item.docDomain + " " + (item.thi rdParty ? docDomainThirdParty : docDomainFirstParty)); |
290 } | 285 } |
291 | 286 |
292 if (filter) | 287 if (filter) |
293 { | 288 { |
294 let filterField = E("tooltipFilter"); | 289 let filterField = E("tooltipFilter"); |
295 setMultilineContent(filterField, filter.text); | 290 setMultilineContent(filterField, filter.text); |
296 if (filter.disabled) | 291 if (filter.disabled) |
297 { | 292 { |
298 let disabledText = document.createElement("description"); | 293 let disabledText = document.createElement("description"); |
299 disabledText.className = "disabledTextLabel"; | 294 disabledText.className = "disabledTextLabel"; |
300 disabledText.textContent = filterField.getAttribute("disabledText"); | 295 disabledText.textContent = filterField.getAttribute("disabledText"); |
301 filterField.appendChild(disabledText); | 296 filterField.appendChild(disabledText); |
302 } | 297 } |
303 | 298 |
304 if (subscriptions.length) | 299 if (subscriptions.length) |
305 { | 300 { |
306 let sourceElement = E("tooltipFilterSource"); | 301 let sourceElement = E("tooltipFilterSource"); |
307 while (sourceElement.firstChild) | 302 while (sourceElement.firstChild) |
308 sourceElement.removeChild(sourceElement.firstChild); | 303 sourceElement.removeChild(sourceElement.firstChild); |
309 for (let i = 0; i < subscriptions.length; i++) | 304 for (let i = 0; i < subscriptions.length; i++) |
310 setMultilineContent(sourceElement, subscriptions[i].title, true); | 305 setMultilineContent(sourceElement, subscriptions[i].title, true); |
311 } | 306 } |
312 } | 307 } |
313 | 308 |
309 let updateSize = function() | |
310 { | |
311 let size = ("tooltip" in item ? null : getItemSize(item, updateSize)); | |
312 E("tooltipSizeRow").hidden = !size; | |
313 if (size) | |
314 E("tooltipSize").setAttribute("value", size.join(" x ")); | |
315 }; | |
316 updateSize(); | |
Thomas Greiner
2015/11/24 14:02:19
`getItemSize` no longer returns the result synchro
Wladimir Palant
2015/11/25 22:22:49
Sorting and tree view don't work asynchronously, t
| |
317 | |
314 var showPreview = Prefs.previewimages && !("tooltip" in item); | 318 var showPreview = Prefs.previewimages && !("tooltip" in item); |
315 showPreview = showPreview && item.type == "IMAGE"; | 319 showPreview = showPreview && item.type == "IMAGE"; |
316 showPreview = showPreview && (!filter || filter.disabled || filter instanceof WhitelistFilter); | 320 showPreview = showPreview && (!filter || filter.disabled || filter instanceof WhitelistFilter); |
317 E("tooltipPreviewBox").hidden = true; | 321 E("tooltipPreviewBox").hidden = true; |
318 if (showPreview) | 322 if (showPreview) |
319 { | 323 { |
320 if (!cacheStorage) | 324 if (!cacheStorage) |
321 { | 325 { |
322 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); | 326 let {Services} = Cu.import("resource://gre/modules/Services.jsm", null); |
323 // Cache v2 API is enabled by default starting with Gecko 32 | 327 // Cache v2 API is enabled by default starting with Gecko 32 |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 let myPrefs = Prefs; | 662 let myPrefs = Prefs; |
659 let myMainWin = mainWin; | 663 let myMainWin = mainWin; |
660 | 664 |
661 // Close sidebar and open detached window | 665 // Close sidebar and open detached window |
662 myMainWin.document.getElementById("abp-command-sidebar").doCommand(); | 666 myMainWin.document.getElementById("abp-command-sidebar").doCommand(); |
663 myPrefs.detachsidebar = doDetach; | 667 myPrefs.detachsidebar = doDetach; |
664 myMainWin.document.getElementById("abp-command-sidebar").doCommand(); | 668 myMainWin.document.getElementById("abp-command-sidebar").doCommand(); |
665 } | 669 } |
666 | 670 |
667 // Returns items size in the document if available | 671 // Returns items size in the document if available |
668 function getItemSize(item) | 672 function getItemSize(item, retryCallback) |
669 { | 673 { |
674 if ("size" in item) | |
675 return item.size; | |
676 | |
670 let filter = getFilter(item); | 677 let filter = getFilter(item); |
671 if (filter && !filter.disabled && filter instanceof BlockingFilter) | 678 if (filter && !filter.disabled && filter instanceof BlockingFilter) |
672 return null; | 679 return null; |
673 | 680 |
674 for (let node of item.nodes) | 681 if (requestNotifier) |
675 { | 682 { |
676 if (node instanceof HTMLImageElement && (node.naturalWidth || node.naturalHe ight)) | 683 requestNotifier.retrieveNodeSize(item.ids, function(size) |
677 return [node.naturalWidth, node.naturalHeight]; | 684 { |
678 else if (node instanceof HTMLElement && (node.offsetWidth || node.offsetHeig ht)) | 685 item.size = size; |
679 return [node.offsetWidth, node.offsetHeight]; | 686 if (retryCallback) |
687 retryCallback(); | |
688 }); | |
680 } | 689 } |
681 return null; | 690 return null; |
682 } | 691 } |
683 | 692 |
684 // Sort functions for the item list | 693 // Sort functions for the item list |
685 function sortByAddress(item1, item2) { | 694 function sortByAddress(item1, item2) { |
686 if (item1.location < item2.location) | 695 if (item1.location < item2.location) |
687 return -1; | 696 return -1; |
688 else if (item1.location > item2.location) | 697 else if (item1.location > item2.location) |
689 return 1; | 698 return 1; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 return ""; | 878 return ""; |
870 if (this.data && this.data.length) { | 879 if (this.data && this.data.length) { |
871 if (row >= this.data.length) | 880 if (row >= this.data.length) |
872 return ""; | 881 return ""; |
873 if (col == "type") | 882 if (col == "type") |
874 return localizedTypes.get(this.data[row].type); | 883 return localizedTypes.get(this.data[row].type); |
875 else if (col == "filter") | 884 else if (col == "filter") |
876 return (this.data[row].filter || ""); | 885 return (this.data[row].filter || ""); |
877 else if (col == "size") | 886 else if (col == "size") |
878 { | 887 { |
879 let size = getItemSize(this.data[row]); | 888 let size = getItemSize(this.data[row], () => |
889 { | |
890 this.boxObject.invalidateRow(row); | |
891 }); | |
880 return (size ? size.join(" x ") : ""); | 892 return (size ? size.join(" x ") : ""); |
881 } | 893 } |
882 else if (col == "docDomain") | 894 else if (col == "docDomain") |
883 return this.data[row].docDomain + " " + (this.data[row].thirdParty ? doc DomainThirdParty : docDomainFirstParty); | 895 return this.data[row].docDomain + " " + (this.data[row].thirdParty ? doc DomainThirdParty : docDomainFirstParty); |
884 else if (col == "filterSource") | 896 else if (col == "filterSource") |
885 { | 897 { |
886 let filter = getFilter(this.data[row]) | 898 let filter = getFilter(this.data[row]) |
887 if (!filter) | 899 if (!filter) |
888 return ""; | 900 return ""; |
889 | 901 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1278 return {tooltip: this.itemsDummyTooltip}; | 1290 return {tooltip: this.itemsDummyTooltip}; |
1279 }, | 1291 }, |
1280 | 1292 |
1281 invalidateItem: function(item) | 1293 invalidateItem: function(item) |
1282 { | 1294 { |
1283 let row = this.data.indexOf(item); | 1295 let row = this.data.indexOf(item); |
1284 if (row >= 0) | 1296 if (row >= 0) |
1285 this.boxObject.invalidateRow(row); | 1297 this.boxObject.invalidateRow(row); |
1286 } | 1298 } |
1287 } | 1299 } |
OLD | NEW |