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

Unified Diff: chrome/content/ui/sidebar.js

Issue 29329786: Issue 3258 - Blockable items: fix Size column (Closed)
Patch Set: Better handling of dead objects Created Nov. 5, 2015, 11:06 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/child/requestNotifier.js » ('j') | lib/requestNotifier.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
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
+
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)
« no previous file with comments | « no previous file | lib/child/requestNotifier.js » ('j') | lib/requestNotifier.js » ('J')

Powered by Google App Engine
This is Rietveld