diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index abaf0248..720209b1 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -113,14 +113,14 @@ var TreeStyleTabService = { { aTabBrowser = aTabBrowser || this.browser; var max = Math.max(window.outerWidth, parseInt(document.documentElement.getAttribute('width') || 0)); - return Math.min(aWidth, max * 0.7); + return Math.min(aWidth, max * this.DEFAULT_SHRUNKEN_WIDTH_RATIO); }, maxTabbarHeight : function TSTService_maxTabbarHeight(aHeight, aTabBrowser) { aTabBrowser = aTabBrowser || this.browser; var max = Math.max(window.outerHeight, parseInt(document.documentElement.getAttribute('height') || 0)); - return Math.min(aHeight, max * 0.7); + return Math.min(aHeight, max * this.DEFAULT_SHRUNKEN_WIDTH_RATIO); }, /* Initializing */ diff --git a/modules/utils.js b/modules/utils.js index 50014818..605540dd 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -143,6 +143,9 @@ var TreeStyleTabUtils = { kINSERT_FISRT : 0, kINSERT_LAST : 1, + + MAX_TABBAR_SIZE_RATIO : 0.8, + DEFAULT_SHRUNKEN_WIDTH_RATIO : 0.67, /* base variables */ baseIndent : 12, @@ -1723,14 +1726,27 @@ var TreeStyleTabUtils = { { var expanded = this.getTreePref('tabbar.width'); var shrunken = this.getTreePref('tabbar.shrunkenWidth'); - if (expanded <= shrunken) { + var originalExpanded = expanded; + var originalShrunken = shrunken; + if (aPrefName == 'extensions.treestyletab.tabbar.shrunkenWidth') { + if (expanded <= shrunken) + expanded = parseInt(shrunken / this.DEFAULT_SHRUNKEN_WIDTH_RATIO) + let w = this.browserWindow; + if (w && expanded > w.gBrowser.boxObject.width) { + expanded = w.gBrowser.boxObject.width * this.MAX_TABBAR_SIZE_RATIO; + if (expanded <= shrunken) + shrunken = parseInt(expanded * this.DEFAULT_SHRUNKEN_WIDTH_RATIO) + } + } + else { + if (expanded <= shrunken) + shrunken = parseInt(expanded * this.DEFAULT_SHRUNKEN_WIDTH_RATIO); + } + if (expanded != originalExpanded || + shrunken != originalShrunken) { this.tabbarWidthResetting = true; - var w = this.browserWindow; - if (w) expanded = Math.min(expanded, w.outerWidth); - if (aPrefName == 'extensions.treestyletab.tabbar.width') - this.setTreePref('tabbar.shrunkenWidth', parseInt(expanded / 1.5)); - else - this.setTreePref('tabbar.width', parseInt(shrunken * 1.5)); + this.setTreePref('tabbar.width', expanded); + this.setTreePref('tabbar.shrunkenWidth', shrunken); this.tabbarWidthResetting = false; } },