From 5ba83972c4713b9245ca9220fc26e6ed6e6eeb1d Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Sat, 22 Jan 2011 23:43:55 +0900 Subject: [PATCH] the orient of the tab bar was wrongly recognized when sycnReinitiTabbar. --- content/treestyletab/treestyletab.js | 5 +- content/treestyletab/treestyletabbrowser.js | 63 ++++++++++----------- modules/tabbarDNDObserver.js | 27 ++++++--- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index fe7e1625..854d0e36 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1231,7 +1231,7 @@ var TreeStyleTabService = { this._tabsOnTopDefaultState = TabsOnTop.enabled; if (gBrowser.treeStyleTab.currentTabbarPosition != 'top' || - !gBrowser.treeStyleTab.isFixed) { + !gBrowser.treeStyleTab.fixed) { if (TabsOnTop.enabled) TabsOnTop.enabled = false; } @@ -1359,7 +1359,8 @@ var TreeStyleTabService = { var orient = b.treeStyleTab.isVertical ? 'vertical' : 'horizontal' ; var newFixed = b.getAttribute(this.kFIXED+'-'+orient) != 'true'; - this.setTabbrowserAttribute(this.kFIXED+'-'+orient, newFixed ? 'true' : null, b); + this.setTabbrowserAttribute(this.kFIXED+'-'+orient, newFixed || null, this.mTabBrowser); + b.treeStyleTab.fixed = newFixed; this.setTreePref('tabbar.fixed.'+orient, newFixed); b.treeStyleTab.updateTabbarState(); diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index d3e15e48..26461b6a 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -151,6 +151,10 @@ TreeStyleTabBrowser.prototype = { var b = this.mTabBrowser; if (!b) return false; + + if (b.hasAttribute(this.kMODE)) + return b.getAttribute(this.kMODE) == 'vertical'; + var box = this.scrollBox || b.mTabContainer ; return (box.getAttribute('orient') || window.getComputedStyle(box, '').getPropertyValue('-moz-box-orient')) == 'vertical'; }, @@ -160,7 +164,7 @@ TreeStyleTabBrowser.prototype = { return this._tabStripPlaceHolder; }, - get isFixed() + get fixed() { var orient = this.isVertical ? 'vertical' : 'horizontal' ; if (!this.preInitialized) @@ -170,6 +174,15 @@ TreeStyleTabBrowser.prototype = { if (!b) return false; return b.getAttribute(this.kFIXED+'-'+orient) == 'true'; }, + set fixed(aValue) + { + this.setTabbrowserAttribute(this.kFIXED, aValue || null, this.mTabBrowser); + return aValue; + }, + get isFixed() // for backward compatibility + { + return this.fixed; + }, get canStackTabs() { @@ -1171,14 +1184,14 @@ TreeStyleTabBrowser.prototype = { var toggleTabsOnTop = document.getElementById('cmd_ToggleTabsOnTop'); if (this.isVertical) { orient = 'vertical'; - this.setTabbrowserAttribute(this.kFIXED, this.isFixed ? 'true' : null , b); + this.fixed = this.fixed; // ensure set to the current orient if (toggleTabsOnTop) toggleTabsOnTop.setAttribute('disabled', true); } else { orient = 'horizontal'; - if (this.isFixed) { - this.setTabbrowserAttribute(this.kFIXED, true, b); + if (this.fixed) { + this.fixed = true; // ensure set to the current orient if (!this.isMultiRow()) { this.removeTabStripAttribute('height'); b.mPanelContainer.removeAttribute('height'); @@ -1196,7 +1209,7 @@ TreeStyleTabBrowser.prototype = { } } else { - this.removeTabbrowserAttribute(this.kFIXED, b); + this.fixed = false; // ensure set to the current orient this.setTabStripAttribute('height', this.maxTabbarHeight(this.getTreePref('tabbar.height'), b)); } if (toggleTabsOnTop) { @@ -1208,7 +1221,7 @@ TreeStyleTabBrowser.prototype = { } if ('TabsOnTop' in window) - TabsOnTop.enabled = TabsOnTop.enabled && this.currentTabbarPosition == 'top' && this.isFixed; + TabsOnTop.enabled = TabsOnTop.enabled && this.currentTabbarPosition == 'top' && this.fixed; window.setTimeout(function(aSelf) { aSelf.updateFloatingTabbar(aSelf.kTABBAR_UPDATE_BY_APPEARANCE_CHANGE); @@ -1236,7 +1249,7 @@ TreeStyleTabBrowser.prototype = { var b = this.mTabBrowser; var orient = this.isVertical ? 'vertical' : 'horizontal' ; var oldState = { - fixed : this.isFixed, + fixed : this.fixed, maxTreeLevel : this.maxTreeLevel, indented : this.maxTreeLevel != 0, canCollapse : b.getAttribute(this.kALLOW_COLLAPSE) == 'true' @@ -1280,7 +1293,7 @@ TreeStyleTabBrowser.prototype = { { var b = this.mTabBrowser; var state = { - fixed : this.isFixed, + fixed : this.fixed, maxTreeLevel : this.maxTreeLevel, indented : this.maxTreeLevel != 0, canCollapse : b.getAttribute(this.kALLOW_COLLAPSE) == 'true' @@ -1501,19 +1514,6 @@ TreeStyleTabBrowser.prototype = { { this.mTabBrowser.mTabContainer.parentNode.classList.add(this.kTABBAR_TOOLBAR); - if (!this._lastTabbarFixedBeforeDestroyed && this.isFixed) { - let self = this; - this.doAndWaitDOMEvent( - this.kEVENT_TYPE_TABBAR_STATE_CHANGED, - window, - 100, - function() { - self.toggleFixed(); - delete self._lastTabbarFixedBeforeDestroyed; - } - ); - } - if (this._lastTabbarPositionBeforeDestroyed) { let self = this; this.doAndWaitDOMEvent( @@ -1522,11 +1522,12 @@ TreeStyleTabBrowser.prototype = { 100, function() { self.initTabbar(self._lastTabbarPositionBeforeDestroyed, 'top'); - delete self._lastTabbarPositionBeforeDestroyed; } ); - this.updateFloatingTabbar(this.kTABBAR_UPDATE_NOW); + delete this._lastTabbarPositionBeforeDestroyed; } + + this.tabbarDNDObserver.startListenEvents(); }, destroy : function TSTBrowser_destroy() @@ -1641,16 +1642,8 @@ TreeStyleTabBrowser.prototype = { ); } - if (!this.isFixed) { - this._lastTabbarFixedBeforeDestroyed = this.isFixed; - let self = this; - this.doAndWaitDOMEvent( - this.kEVENT_TYPE_TABBAR_STATE_CHANGED, - window, - 100, - function() { self.toggleFixed(); } - ); - } + if (!this.fixed) + this.fixed = true; this.updateFloatingTabbar(this.kTABBAR_UPDATE_NOW); this.removeTabStripAttribute('width'); @@ -1658,6 +1651,8 @@ TreeStyleTabBrowser.prototype = { this.removeTabStripAttribute('ordinal'); this._endListenTabbarEvents(); + this.tabbarDNDObserver.endListenEvents(); + this.mTabBrowser.mTabContainer.parentNode.classList.remove(this.kTABBAR_TOOLBAR); }, @@ -3562,7 +3557,7 @@ TreeStyleTabBrowser.prototype = { if ( !aEnabled || this.currentTabbarPosition != 'top' || - this.isFixed + this.fixed ) return; window.setTimeout(function(aTabBrowser) { diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index 14c7c57e..983f0e2c 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -33,7 +33,7 @@ * * ***** END LICENSE BLOCK ******/ -const EXPORTED_SYMBOLS = ['TabbarDNDObserver']; +const EXPORTED_SYMBOLS = ['TabbarDNDObserver']; const Cc = Components.classes; const Ci = Components.interfaces; @@ -1119,7 +1119,11 @@ catch(e) { this.mAutoExpandTimer = null; this.mAutoExpandedTabs = []; - + this.startListenEvents(); + }, + + startListenEvents : function TabbarDND_startListenEvents() + { var strip = this.treeStyleTab.tabStrip; strip.addEventListener('dragstart', this, true); strip.addEventListener('dragover', this, true); @@ -1128,8 +1132,18 @@ catch(e) { strip.addEventListener('dragend', this, false); strip.addEventListener('drop', this, true); }, - + destroy : function TabbarDND_destroy() + { + this.endListenEvents(); + + delete this.treeStyleTab; + delete this.browser; + delete this.document; + delete this.window; + }, + + endListenEvents : function TabbarDND_endListenEvents() { var strip = this.treeStyleTab.tabStrip; strip.removeEventListener('dragstart', this, true); @@ -1138,12 +1152,7 @@ catch(e) { strip.removeEventListener('dragleave', this, false); strip.removeEventListener('dragend', this, false); strip.removeEventListener('drop', this, true); - - delete this.treeStyleTab; - delete this.browser; - delete this.document; - delete this.window; } - + };