Calculate required size for a tree more smartly

This commit is contained in:
Piro / YUKI Hiroshi 2016-03-06 00:34:27 +09:00
parent a173ed4e66
commit c42e2415d8
2 changed files with 24 additions and 33 deletions

View File

@ -543,8 +543,8 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
{ {
log('expandTooltip'); log('expandTooltip');
var tooltip = this.tabFullTooltip; var tooltip = this.tabFullTooltip;
var tree = this.tree;
{ {
let tree = this.tree;
let basePosition = this.windowBasePosition; let basePosition = this.windowBasePosition;
let tooltipBox = tooltip.boxObject; let tooltipBox = tooltip.boxObject;
log(' => initial dimension: ', { log(' => initial dimension: ', {
@ -563,13 +563,12 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
this.lastScreen = this.getCurrentScreen(tooltip.boxObject); this.lastScreen = this.getCurrentScreen(tooltip.boxObject);
var header = this.tree.previousSibling; this.determineTreeSize();
var extraHeight = header && header.boxObject.height || 0; this.expandTooltipInternal();
},
var treeBox = { determineTreeSize : function FTM_determineTreeSize()
width : tree.clientWidth, {
height : tree.clientHeight var tree = this.tree;
};
var columnize = utils.getTreePref('tooltip.columnize'); var columnize = utils.getTreePref('tooltip.columnize');
if (columnize) { if (columnize) {
@ -583,20 +582,22 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
}); });
} }
this.window.setTimeout((function() { var range = this.document.createRange();
if (!columnize || tree.columnCount != 1) range.selectNodeContents(tree);
treeBox = tree.boxObject; if (tree.previousSibling)
range.setStartBefore(tree.previousSibling);
var rect = range.getBoundingClientRect();
range.detach();
var container = this.container; var container = this.container;
var containerStyle = container.style;
var arrowScrollBox = container.parentNode;
var scrollButtonsMargin = (arrowScrollBox.boxObject.width - arrowScrollBox._scrollbox.boxObject.width);
scrollButtonsMargin *= 2; // enough width to deactivate scroll buttons.
containerStyle.width = (container.width = treeBox.width + scrollButtonsMargin)+'px';
containerStyle.height = (container.height = (treeBox.height + extraHeight))+'px';
this.expandTooltipInternal(); var arrowScrollBox = container.parentNode;
}).bind(this), 0); var scrollButtonsMargin = (arrowScrollBox.boxObject.width - arrowScrollBox._scrollbox.boxObject.width);
scrollButtonsMargin *= 2; // enough width to deactivate scroll buttons.
var containerStyle = container.style;
containerStyle.width = (container.width = rect.width + scrollButtonsMargin)+'px';
containerStyle.height = (container.height = rect.height)+'px';
}, },
expandTooltipInternal : function FTM_expandTooltipInternal() expandTooltipInternal : function FTM_expandTooltipInternal()
{ {

View File

@ -172,22 +172,12 @@ var PseudoTreeBuilder = {
style.height = style.maxHeight = style.height = style.maxHeight =
Math.floor(containerBox.height * 0.9) + 'px'; Math.floor(containerBox.height * 0.9) + 'px';
aTree.columnCount = 0; aTree.columnCount = this.getActualColumnCount(aTree);
aTree.ownerDocument.defaultView.setTimeout((function() { if (aTree.columnCount == 1)
aTree.columnCount = this.getActualColumnCount(aTree); style.columnWidth = style.MozColumnWidth = '';
if (aTree.columnCount == 1)
style.columnWidth = style.MozColumnWidth = '';
if (aOptions.calculateCount) {
// This is required to expand the size of the box.
style.columnCount =
style.MozColumnCount =
aTree.columnCount;
}
}).bind(this), 0);
} }
else { else {
style.height = style.maxHeight = ''; style.height = style.maxHeight = '';
aTree.columnCount = 1;
} }
}, },
getActualColumnCount : function TB_getActualColumnCount(aTree) getActualColumnCount : function TB_getActualColumnCount(aTree)