Calculate number of columns by self only when it is needed

This commit is contained in:
Piro / YUKI Hiroshi 2016-03-04 22:26:26 +09:00
parent 8506d7e4d7
commit 7710adbd9a
2 changed files with 26 additions and 13 deletions

View File

@ -602,8 +602,11 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
if (utils.getTreePref('tooltip.columnize')) { if (utils.getTreePref('tooltip.columnize')) {
PseudoTreeBuilder.columnizeTree(tree, { PseudoTreeBuilder.columnizeTree(tree, {
containerBox : {
width : this.lastScreen.allowedWidth, width : this.lastScreen.allowedWidth,
height : this.lastScreen.allowedHeight height : this.lastScreen.allowedHeight
},
calculateCount : true
}); });
this.window.setTimeout(this.expandTooltipInternal.bind(this), 0); this.window.setTimeout(this.expandTooltipInternal.bind(this), 0);
} }

View File

@ -146,32 +146,42 @@ var PseudoTreeBuilder = {
return container; return container;
}, },
columnizeTree : function TB_columnizeTree(aTree, aContainerBox) columnizeTree : function TB_columnizeTree(aTree, aOptions)
{ {
if (!aTree) if (!aTree)
return; return;
aContainerBox = aContainerBox || aTree.parentNode.boxObject; aOptions = aOptions || {};
var containerBox = aOptions.containerBox || aTree.parentNode.boxObject;
var style = aTree.style; var style = aTree.style;
var height = aTree.clientHeight * (aTree.columnCount || 1); var height = aTree.clientHeight * (aTree.columnCount || 1);
if (height > aContainerBox.height && if (height > containerBox.height &&
aContainerBox.height < aContainerBox.width) { containerBox.height < containerBox.width) {
let maxWidth = aContainerBox.width; let maxWidth = containerBox.width;
aTree.columnWidth = Math.floor(maxWidth * 0.9 / 2.5); aTree.columnWidth = Math.floor(maxWidth * 0.9 / 2.5);
style.columnWidth = style.MozColumnWidth = aTree.columnWidth+'px';
style.columnGap = style.MozColumnGap = '0';
style.columnFill = style.MozColumnFill = 'auto';
if (aOptions.calculateCount) {
let count = Math.ceil( let count = Math.ceil(
(Math.max(aTree.clientWidth, maxWidth) * aTree.clientHeight) / (Math.max(aTree.clientWidth, maxWidth) * aTree.clientHeight) /
(aTree.columnWidth * aTree.clientHeight) (aTree.columnWidth * aTree.clientHeight)
); );
aTree.columnCount = style.columnCount = style.MozColumnCount = count; aTree.columnCount = style.columnCount = style.MozColumnCount = count;
style.columnWidth = style.MozColumnWidth = aTree.columnWidth+'px'; }
style.columnGap = style.MozColumnGap = '0'; else {
style.columnFill = style.MozColumnFill = 'auto'; aTree.columnCount = 2;
style.columnCount = style.MozColumnCount = 'auto';
}
aTree.ownerDocument.defaultView.setTimeout((function() { aTree.ownerDocument.defaultView.setTimeout((function() {
let columnCount = this.getActualColumnCount(aTree); aTree.columnCount = this.getActualColumnCount(aTree);
aTree.columnCount = style.columnCount = if (aOptions.calculateCount) {
style.MozColumnCount = columnCount; style.columnCount =
style.MozColumnCount =
aTree.columnCount;
}
}).bind(this), 0); }).bind(this), 0);
} }
else { else {
@ -179,12 +189,12 @@ var PseudoTreeBuilder = {
style.columnCount = style.MozColumnCount = style.columnCount = style.MozColumnCount =
style.columnWidth = style.MozColumnWidth = style.columnWidth = style.MozColumnWidth =
style.columnGap = style.MozColumnGap = style.columnGap = style.MozColumnGap =
style.columnFill = style.MozColumnFill; style.columnFill = style.MozColumnFill = '';
} }
if (aTree.columnCount > 1) { if (aTree.columnCount > 1) {
style.height = style.maxHeight = style.height = style.maxHeight =
Math.floor(aContainerBox.height * 0.9) + 'px'; Math.floor(containerBox.height * 0.9) + 'px';
} }
else { else {
style.height = style.maxHeight = ''; style.height = style.maxHeight = '';