Rearrange methods by their executed order
This commit is contained in:
parent
b040f2db20
commit
115cbc1e61
@ -95,6 +95,65 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
||||
return this.tabFullTooltip.lastChild.lastChild.lastChild;
|
||||
},
|
||||
|
||||
/**
|
||||
* If the window is maximized, screenX and screenY can be out of
|
||||
* visible screen rect. On the other hand,
|
||||
* PopupBoxObject#openPopupAtScreen() automatically reposition
|
||||
* the popup if it is going to be shown out of the visible screen
|
||||
* rect. As the result, the popup will be repositioned unexpectedly
|
||||
* if I use the raw screenX and screenY.
|
||||
* https://github.com/piroor/treestyletab/issues/302
|
||||
* To prevent such a result, I have to calculate valid base position
|
||||
* for the popup.
|
||||
*/
|
||||
get windowBasePosition() {
|
||||
var screen = ScreenManager.screenForRect(
|
||||
this.window.screenX,
|
||||
this.window.screenY,
|
||||
this.window.outerWidth,
|
||||
this.window.outerHeight
|
||||
);
|
||||
var screenMinX = {},
|
||||
screenMinY = {},
|
||||
screenMaxX = {},
|
||||
screenMaxY = {};
|
||||
screen.GetAvailRect(screenMinX, screenMinY, screenMaxX, screenMaxY);
|
||||
|
||||
return {
|
||||
x: Math.max(this.window.screenX, screenMinX.value),
|
||||
y: Math.max(this.window.screenY, screenMinY.value)
|
||||
};
|
||||
},
|
||||
|
||||
getCurrentScreen : function FTM_getCurrentScreen(aBox)
|
||||
{
|
||||
var currentScreen = Cc['@mozilla.org/gfx/screenmanager;1']
|
||||
.getService(Ci.nsIScreenManager)
|
||||
.screenForRect(aBox.screenX, aBox.screenY, aBox.width, aBox.height);
|
||||
var screenLeft = {},
|
||||
screenTop = {},
|
||||
screenWidth = {},
|
||||
screenHeight = {};
|
||||
currentScreen.GetRect(screenLeft, screenTop, screenWidth, screenHeight);
|
||||
return {
|
||||
left : screenLeft.value,
|
||||
top : screenTop.value,
|
||||
width : screenWidth.value,
|
||||
height : screenHeight.value,
|
||||
allowedWidth : Math.ceil(screenWidth.value * 0.8),
|
||||
allowedHeight : Math.ceil(screenHeight.value * 0.7)
|
||||
};
|
||||
},
|
||||
|
||||
getFullTooltipFromEvent : function FTM_getFullTooltipFromEvent(aEvent)
|
||||
{
|
||||
return utils.evaluateXPath(
|
||||
'ancestor-or-self::xul:tooltip[@id="'+this.tabFullTooltip.id+'"]',
|
||||
aEvent.target,
|
||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
||||
).singleNodeValue;
|
||||
},
|
||||
|
||||
|
||||
init : function FTM_init(aOwner)
|
||||
{
|
||||
@ -184,15 +243,6 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
||||
}
|
||||
},
|
||||
|
||||
getFullTooltipFromEvent : function FTM_getFullTooltipFromEvent(aEvent)
|
||||
{
|
||||
return utils.evaluateXPath(
|
||||
'ancestor-or-self::xul:tooltip[@id="'+this.tabFullTooltip.id+'"]',
|
||||
aEvent.target,
|
||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
||||
).singleNodeValue;
|
||||
},
|
||||
|
||||
onClick : function FTM_onClick(aEvent)
|
||||
{
|
||||
this.tabFullTooltip.hidePopup();
|
||||
@ -226,104 +276,11 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
||||
this.cancel();
|
||||
},
|
||||
|
||||
getCurrentScreen : function FTM_getCurrentScreen(aBox)
|
||||
{
|
||||
var currentScreen = Cc['@mozilla.org/gfx/screenmanager;1']
|
||||
.getService(Ci.nsIScreenManager)
|
||||
.screenForRect(aBox.screenX, aBox.screenY, aBox.width, aBox.height);
|
||||
var screenLeft = {},
|
||||
screenTop = {},
|
||||
screenWidth = {},
|
||||
screenHeight = {};
|
||||
currentScreen.GetRect(screenLeft, screenTop, screenWidth, screenHeight);
|
||||
return {
|
||||
left : screenLeft.value,
|
||||
top : screenTop.value,
|
||||
width : screenWidth.value,
|
||||
height : screenHeight.value,
|
||||
allowedWidth : Math.ceil(screenWidth.value * 0.8),
|
||||
allowedHeight : Math.ceil(screenHeight.value * 0.7)
|
||||
};
|
||||
},
|
||||
|
||||
onShown : function FTM_onShown(aEvent)
|
||||
{
|
||||
log('onShown');
|
||||
this.startListenTooltipEvents();
|
||||
|
||||
var tooltip = this.tabFullTooltip;
|
||||
var tree = this.tree;
|
||||
log(' => tooltip: ', {
|
||||
x : tooltip.boxObject.screenX,
|
||||
y : tooltip.boxObject.screenY,
|
||||
width : tooltip.boxObject.width,
|
||||
height : tooltip.boxObject.height
|
||||
});
|
||||
log(' => tree: ', {
|
||||
width : tree.clientWidth,
|
||||
height : tree.clientHeight
|
||||
});
|
||||
|
||||
if (utils.getTreePref('tooltip.columnize')) {
|
||||
let currentScreen = this.getCurrentScreen(tooltip.boxObject);
|
||||
PseudoTreeBuilder.columnizeTree(tree, {
|
||||
width : currentScreen.allowedWidth,
|
||||
height : currentScreen.allowedHeight
|
||||
});
|
||||
this.window.setTimeout(this.resizeTooltip.bind(this), 0);
|
||||
}
|
||||
else {
|
||||
this.resizeTooltip();
|
||||
}
|
||||
},
|
||||
resizeTooltip : function FTM_resizeTooltip()
|
||||
{
|
||||
log('resizeTooltip');
|
||||
var tooltip = this.tabFullTooltip;
|
||||
tooltip.setAttribute('popup-shown', true);
|
||||
|
||||
var w = {},
|
||||
h = {};
|
||||
var box = tooltip.boxObject;
|
||||
var scrollBoxObject = tooltip.firstChild.scrollBoxObject;
|
||||
scrollBoxObject.getScrolledSize(w, h);
|
||||
var currentW = box.width - scrollBoxObject.width + w.value;
|
||||
var currentH = box.height - scrollBoxObject.height + h.value;
|
||||
var currentX = box.screenX;
|
||||
var currentY = box.screenY;
|
||||
|
||||
var currentScreen = this.getCurrentScreen(box);
|
||||
log(' => currentScreen: ', currentScreen);
|
||||
|
||||
var style = tooltip.style;
|
||||
style.maxWidth = currentScreen.allowedWidth+'px';
|
||||
style.maxHeight = currentScreen.allowedHeight+'px';
|
||||
style.minWidth = 0;
|
||||
style.minHeight = 0;
|
||||
if (currentX + currentW + currentScreen.left >= currentScreen.allowedWidth)
|
||||
style.marginLeft = (Math.max(currentScreen.left, currentScreen.allowedWidth - currentW) - this.window.screenX)+'px';
|
||||
if (currentY + currentH + currentScreen.top >= currentScreen.allowedHeight)
|
||||
style.marginTop = (Math.max(currentScreen.top, currentScreen.allowedHeight - currentH) - this.window.screenY)+'px';
|
||||
log(' => tooltip: ', {
|
||||
left : style.marginLeft,
|
||||
top : style.marginTop,
|
||||
width : style.width,
|
||||
height : style.height
|
||||
});
|
||||
|
||||
{
|
||||
// Let's maximize the container box enough to show the tree.
|
||||
// If the tree is larger thant the tooltip,
|
||||
// it becomes scrollable by arrowscrollbox.
|
||||
let tree = this.tree;
|
||||
let style = this.container.style;
|
||||
style.width = tree.clientWidth+'px';
|
||||
style.height = tree.clientHeight+'px';
|
||||
log(' => tree: ', {
|
||||
width : tree.clientWidth,
|
||||
height : tree.clientHeight
|
||||
});
|
||||
}
|
||||
this.expandTooltip();
|
||||
},
|
||||
|
||||
onHidden : function FTM_onHidden(aEvent)
|
||||
@ -450,37 +407,6 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
||||
this.setup(aEvent.target, tab, fullTooltipExtraLabel);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* If the window is maximized, screenX and screenY can be out of
|
||||
* visible screen rect. On the other hand,
|
||||
* PopupBoxObject#openPopupAtScreen() automatically reposition
|
||||
* the popup if it is going to be shown out of the visible screen
|
||||
* rect. As the result, the popup will be repositioned unexpectedly
|
||||
* if I use the raw screenX and screenY.
|
||||
* https://github.com/piroor/treestyletab/issues/302
|
||||
* To prevent such a result, I have to calculate valid base position
|
||||
* for the popup.
|
||||
*/
|
||||
get windowBasePosition() {
|
||||
var screen = ScreenManager.screenForRect(
|
||||
this.window.screenX,
|
||||
this.window.screenY,
|
||||
this.window.outerWidth,
|
||||
this.window.outerHeight
|
||||
);
|
||||
var screenMinX = {},
|
||||
screenMinY = {},
|
||||
screenMaxX = {},
|
||||
screenMaxY = {};
|
||||
screen.GetAvailRect(screenMinX, screenMinY, screenMaxX, screenMaxY);
|
||||
|
||||
return {
|
||||
x: Math.max(this.window.screenX, screenMinX.value),
|
||||
y: Math.max(this.window.screenY, screenMinY.value)
|
||||
};
|
||||
},
|
||||
|
||||
setup : function FTM_setup(aBaseTooltip, aTab, aExtraLabels)
|
||||
{
|
||||
log('setup');
|
||||
@ -523,7 +449,7 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
||||
}).bind(this), Math.max(delay, 0), this);
|
||||
},
|
||||
|
||||
cancel : function FTM_destroyFullTooltip()
|
||||
cancel : function FTM_cancel()
|
||||
{
|
||||
if (this._fullTooltipTimer) {
|
||||
this.window.clearTimeout(this._fullTooltipTimer);
|
||||
@ -600,5 +526,84 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
|
||||
range.selectNodeContents(this.tabFullTooltip);
|
||||
range.deleteContents();
|
||||
range.detach();
|
||||
},
|
||||
|
||||
|
||||
expandTooltip : function FTM_expandTooltip()
|
||||
{
|
||||
log('expandTooltip');
|
||||
var tooltip = this.tabFullTooltip;
|
||||
var tree = this.tree;
|
||||
log(' => tooltip: ', {
|
||||
x : tooltip.boxObject.screenX,
|
||||
y : tooltip.boxObject.screenY,
|
||||
width : tooltip.boxObject.width,
|
||||
height : tooltip.boxObject.height
|
||||
});
|
||||
log(' => tree: ', {
|
||||
width : tree.clientWidth,
|
||||
height : tree.clientHeight
|
||||
});
|
||||
|
||||
if (utils.getTreePref('tooltip.columnize')) {
|
||||
let currentScreen = this.getCurrentScreen(tooltip.boxObject);
|
||||
PseudoTreeBuilder.columnizeTree(tree, {
|
||||
width : currentScreen.allowedWidth,
|
||||
height : currentScreen.allowedHeight
|
||||
});
|
||||
this.window.setTimeout(this.expandTooltipInternal.bind(this), 0);
|
||||
}
|
||||
else {
|
||||
this.expandTooltipInternal();
|
||||
}
|
||||
},
|
||||
expandTooltipInternal : function FTM_expandTooltipInternal()
|
||||
{
|
||||
log('expandTooltipInternal');
|
||||
var tooltip = this.tabFullTooltip;
|
||||
tooltip.setAttribute('popup-shown', true);
|
||||
|
||||
var w = {},
|
||||
h = {};
|
||||
var box = tooltip.boxObject;
|
||||
var scrollBoxObject = tooltip.firstChild.scrollBoxObject;
|
||||
scrollBoxObject.getScrolledSize(w, h);
|
||||
var currentW = box.width - scrollBoxObject.width + w.value;
|
||||
var currentH = box.height - scrollBoxObject.height + h.value;
|
||||
var currentX = box.screenX;
|
||||
var currentY = box.screenY;
|
||||
|
||||
var currentScreen = this.getCurrentScreen(box);
|
||||
log(' => currentScreen: ', currentScreen);
|
||||
|
||||
var style = tooltip.style;
|
||||
style.maxWidth = currentScreen.allowedWidth+'px';
|
||||
style.maxHeight = currentScreen.allowedHeight+'px';
|
||||
style.minWidth = 0;
|
||||
style.minHeight = 0;
|
||||
if (currentX + currentW + currentScreen.left >= currentScreen.allowedWidth)
|
||||
style.marginLeft = (Math.max(currentScreen.left, currentScreen.allowedWidth - currentW) - this.window.screenX)+'px';
|
||||
if (currentY + currentH + currentScreen.top >= currentScreen.allowedHeight)
|
||||
style.marginTop = (Math.max(currentScreen.top, currentScreen.allowedHeight - currentH) - this.window.screenY)+'px';
|
||||
log(' => tooltip: ', {
|
||||
left : style.marginLeft,
|
||||
top : style.marginTop,
|
||||
width : style.width,
|
||||
height : style.height
|
||||
});
|
||||
|
||||
{
|
||||
// Let's maximize the container box enough to show the tree.
|
||||
// If the tree is larger thant the tooltip,
|
||||
// it becomes scrollable by arrowscrollbox.
|
||||
let tree = this.tree;
|
||||
let style = this.container.style;
|
||||
style.width = tree.clientWidth+'px';
|
||||
style.height = tree.clientHeight+'px';
|
||||
log(' => tree: ', {
|
||||
width : tree.clientWidth,
|
||||
height : tree.clientHeight
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user