WIP: try to reduce use of eval() for TabsInTitlebar hack

This commit is contained in:
YUKI Hiroshi 2016-09-05 19:14:26 +09:00
parent 24388b2a02
commit 595252b1eb

View File

@ -49,6 +49,50 @@ var TreeStyleTabWindowHelper = {
'$& gBrowser.treeStyleTab.position != "top" ? 0 : '
));
}, 'treeStyleTab');
/*
TabsInTitlebar.__treestyletab__update = TabsInTitlebar._update;
TabsInTitlebar._update = function(...aArgs) {
// See: https://dxr.mozilla.org/mozilla-central/rev/dbe4b47941c7b3d6298a0ead5e40dd828096c808/browser/base/content/browser-tabsintitlebar.js#104
let isForce = aArgs[0];
let shouldFixMargin = (
gBrowser.treeStyleTab.position != 'top' &&
!window.fullScreen &&
this._initialized &&
(
isForce ||
(
this._lastSizeMode != document.documentElement.getAttribute('sizemode') &&
this._lastSizeMode != 'fullscreen'
)
) &&
Object.keys(this._disallowed).length === 0
);
if (!shouldFixMargin)
return this.__treestyletab__update(...aArgs);
// reset needless margins around the titlebar, from non-top tab bar
let titlebarContent = document.getElementById('titlebar-content');
let titlebarContentHeight = titlebarContent.getBoundingClientRect().height;
let fullTabsHeight = (function() {
let tabsToolbar = document.getElementById('TabsToolbar');
let tabsStyles = window.getComputedStyle(tabsToolbar);
let verticalMargins = parseFloat(tabsStyles.marginBottom) + parseFloat(tabsStyles.marginTop);
return tabsToolbar.getBoundingClientRect().height + verticalMargins;
})();
let result = this.__treestyletab__update(...aArgs);
let titlebar = document.getElementById('titlebar');
let currentMargin = parseFloat(titlebar.style.marginBottom.replace('px', ''));
if (-titlebarContentHeight != currentMargin) {
titlebar.style.marginBottom = (currentMargin + fullTabsHeight) + 'px';
}
return result;
};
*/
}
window.__treestyletab__BrowserOpenTab = window.BrowserOpenTab;