From b7194c201aa8dbff3293a4d1e6e41c632e7342ce Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Wed, 6 Apr 2011 22:04:02 +0900 Subject: [PATCH] fix "too narrow tab bar" probelm automatically (fix for https://github.com/piroor/treestyletab/issues/76 ) --- content/treestyletab/treestyletab.js | 15 ++++++--- content/treestyletab/treestyletabbrowser.js | 34 +++++++++++++++++++++ modules/autoHide.js | 2 ++ 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index dcf4ed6e..88bc6a3b 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1139,18 +1139,23 @@ var TreeStyleTabService = { if (this.tabbarResizeStartWidth < 0) return; - aEvent.stopPropagation(); - if ('releaseCapture' in aEvent.currentTarget) - aEvent.currentTarget.releaseCapture(); + var target = aEvent.currentTarget; + var b = this.getTabBrowserFromChild(target); - aEvent.currentTarget.removeEventListener('mousemove', this, false); + aEvent.stopPropagation(); + if ('releaseCapture' in target) + target.releaseCapture(); + + target.removeEventListener('mousemove', this, false); this.tabbarResizeStartWidth = -1; this.tabbarResizeStartHeight = -1; this.tabbarResizeStartX = -1; this.tabbarResizeStartY = -1; - var b = this.getTabBrowserFromChild(aEvent.currentTarget); + this.Deferred.next(function() { + b.treeStyleTab.fixTooNarrowTabbar(); + }); }, onTabbarResizing : function TSTService_onTabbarResizing(aEvent) { diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index b9d7f542..fc30dc80 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -387,6 +387,39 @@ TreeStyleTabBrowser.prototype = { } ); }, + + fixTooNarrowTabbar : function TSTBrowser_fixTooNarrowTabbar() + { + if (!this.isFloating) return; + /** + * The tab bar can become smaller than the actual size of the + * floating tab bar, and then, we cannot resize tab bar by + * dragging anymore. To avoid this problem, we have to enlarge + * the tab bar larger than the floating tab bar. + */ + if (this.isVertical) { + let key = this.autoHide.expanded ? + 'tabbar.width' : 'tabbar.shrunkenWidth' ; + let width = this.getTreePref(key); + let minWidth = this.scrollBox.boxObject.width + if (minWidth > width) { + this.setPrefForActiveWindow(function() { + this.setTreePref(key, minWidth); + this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE); + }); + } + } + else { + let height = this.getTreePref('tabbar.height'); + let minHeight = this.scrollBox.boxObject.height + if (minHeight > height) { + this.setPrefForActiveWindow(function() { + this.setTreePref('tabbar.height', minHeight); + this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_PREF_CHANGE); + }); + } + } + }, /* initialize */ @@ -460,6 +493,7 @@ TreeStyleTabBrowser.prototype = { this.autoHide; this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_INITIALIZE); + this.fixTooNarrowTabbar(); this.fireTabbarPositionEvent(false, 'top', position); /* PUBLIC API */ diff --git a/modules/autoHide.js b/modules/autoHide.js index c69a3ffd..8059b242 100644 --- a/modules/autoHide.js +++ b/modules/autoHide.js @@ -202,6 +202,8 @@ AutoHideBrowser.prototype = { this.updateTransparency(); this.showHideInternal(); + + b.treeStyleTab.fixTooNarrowTabbar(); }, end : function AHB_end()