Reduce use of eval()
This commit is contained in:
parent
595252b1eb
commit
ab7723d375
@ -43,56 +43,15 @@ var TreeStyleTabWindowHelper = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if ('TabsInTitlebar' in window) {
|
if ('TabsInTitlebar' in window) {
|
||||||
TreeStyleTabUtils.doPatching(TabsInTitlebar._update, 'TabsInTitlebar._update', function(aName, aSource) {
|
|
||||||
return eval(aName+' = '+aSource.replace(
|
|
||||||
/let fullTabsHeight = /,
|
|
||||||
'$& gBrowser.treeStyleTab.position != "top" ? 0 : '
|
|
||||||
));
|
|
||||||
}, 'treeStyleTab');
|
|
||||||
/*
|
|
||||||
TabsInTitlebar.__treestyletab__update = TabsInTitlebar._update;
|
TabsInTitlebar.__treestyletab__update = TabsInTitlebar._update;
|
||||||
TabsInTitlebar._update = function(...aArgs) {
|
TabsInTitlebar._update = function(...aArgs) {
|
||||||
// See: https://dxr.mozilla.org/mozilla-central/rev/dbe4b47941c7b3d6298a0ead5e40dd828096c808/browser/base/content/browser-tabsintitlebar.js#104
|
// 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 result = this.__treestyletab__update(...aArgs);
|
||||||
|
if (gBrowser.treeStyleTab.position != 'top')
|
||||||
let titlebar = document.getElementById('titlebar');
|
document.getElementById('titlebar').style.marginBottom =
|
||||||
let currentMargin = parseFloat(titlebar.style.marginBottom.replace('px', ''));
|
document.getElementById('titlebar-content').style.marginBottom = '';
|
||||||
if (-titlebarContentHeight != currentMargin) {
|
|
||||||
titlebar.style.marginBottom = (currentMargin + fullTabsHeight) + 'px';
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
window.__treestyletab__BrowserOpenTab = window.BrowserOpenTab;
|
window.__treestyletab__BrowserOpenTab = window.BrowserOpenTab;
|
||||||
|
Loading…
Reference in New Issue
Block a user