Index: chrome/content/ui/sidebar.js |
=================================================================== |
--- a/chrome/content/ui/sidebar.js |
+++ b/chrome/content/ui/sidebar.js |
@@ -253,23 +253,21 @@ function fillInTooltip(e) { |
if (!item) |
{ |
e.preventDefault(); |
return; |
} |
let filter = getFilter(item); |
- let size = ("tooltip" in item ? null : getItemSize(item)); |
let subscriptions = (filter ? filter.subscriptions.filter(function(subscription) { return !subscription.disabled; }) : []); |
E("tooltipDummy").hidden = !("tooltip" in item); |
E("tooltipAddressRow").hidden = ("tooltip" in item); |
E("tooltipTypeRow").hidden = ("tooltip" in item); |
- E("tooltipSizeRow").hidden = !size; |
E("tooltipDocDomainRow").hidden = ("tooltip" in item || !item.docDomain); |
E("tooltipFilterRow").hidden = !filter; |
E("tooltipFilterSourceRow").hidden = !subscriptions.length; |
if ("tooltip" in item) |
E("tooltipDummy").setAttribute("value", item.tooltip); |
else |
{ |
@@ -278,19 +276,16 @@ function fillInTooltip(e) { |
var type = localizedTypes.get(item.type); |
if (filter && filter instanceof WhitelistFilter) |
type += " " + E("tooltipType").getAttribute("whitelisted"); |
else if (filter && item.type != "ELEMHIDE") |
type += " " + E("tooltipType").getAttribute("filtered"); |
E("tooltipType").setAttribute("value", type); |
- if (size) |
- E("tooltipSize").setAttribute("value", size.join(" x ")); |
- |
E("tooltipDocDomain").setAttribute("value", item.docDomain + " " + (item.thirdParty ? docDomainThirdParty : docDomainFirstParty)); |
} |
if (filter) |
{ |
let filterField = E("tooltipFilter"); |
setMultilineContent(filterField, filter.text); |
if (filter.disabled) |
@@ -306,16 +301,25 @@ function fillInTooltip(e) { |
let sourceElement = E("tooltipFilterSource"); |
while (sourceElement.firstChild) |
sourceElement.removeChild(sourceElement.firstChild); |
for (let i = 0; i < subscriptions.length; i++) |
setMultilineContent(sourceElement, subscriptions[i].title, true); |
} |
} |
+ let updateSize = function() |
+ { |
+ let size = ("tooltip" in item ? null : getItemSize(item, updateSize)); |
+ E("tooltipSizeRow").hidden = !size; |
+ if (size) |
+ E("tooltipSize").setAttribute("value", size.join(" x ")); |
+ }; |
+ updateSize(); |
+ |
var showPreview = Prefs.previewimages && !("tooltip" in item); |
showPreview = showPreview && item.type == "IMAGE"; |
showPreview = showPreview && (!filter || filter.disabled || filter instanceof WhitelistFilter); |
E("tooltipPreviewBox").hidden = true; |
if (showPreview) |
{ |
if (!cacheStorage) |
{ |
@@ -660,28 +664,33 @@ function detach(doDetach) |
// Close sidebar and open detached window |
myMainWin.document.getElementById("abp-command-sidebar").doCommand(); |
myPrefs.detachsidebar = doDetach; |
myMainWin.document.getElementById("abp-command-sidebar").doCommand(); |
} |
// Returns items size in the document if available |
-function getItemSize(item) |
+function getItemSize(item, retryCallback) |
{ |
+ if ("size" in item) |
+ return item.size; |
+ |
let filter = getFilter(item); |
if (filter && !filter.disabled && filter instanceof BlockingFilter) |
return null; |
- for (let node of item.nodes) |
+ if (requestNotifier) |
{ |
- if (node instanceof HTMLImageElement && (node.naturalWidth || node.naturalHeight)) |
- return [node.naturalWidth, node.naturalHeight]; |
- else if (node instanceof HTMLElement && (node.offsetWidth || node.offsetHeight)) |
- return [node.offsetWidth, node.offsetHeight]; |
+ requestNotifier.retrieveNodeSize(item.ids, function(size) |
+ { |
+ item.size = size; |
+ if (retryCallback) |
+ retryCallback(); |
+ }); |
} |
return null; |
} |
// Sort functions for the item list |
function sortByAddress(item1, item2) { |
if (item1.location < item2.location) |
return -1; |
@@ -871,17 +880,20 @@ var treeView = { |
if (row >= this.data.length) |
return ""; |
if (col == "type") |
return localizedTypes.get(this.data[row].type); |
else if (col == "filter") |
return (this.data[row].filter || ""); |
else if (col == "size") |
{ |
- let size = getItemSize(this.data[row]); |
+ let size = getItemSize(this.data[row], () => |
+ { |
+ this.boxObject.invalidateRow(row); |
+ }); |
return (size ? size.join(" x ") : ""); |
} |
else if (col == "docDomain") |
return this.data[row].docDomain + " " + (this.data[row].thirdParty ? docDomainThirdParty : docDomainFirstParty); |
else if (col == "filterSource") |
{ |
let filter = getFilter(this.data[row]) |
if (!filter) |