From 4fbfd750d271c5adc11a38d44b00a2bb5f4daf92 Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Sun, 23 Jan 2011 02:18:03 +0900 Subject: [PATCH] When the tab bar is moved into the title bar, show/hide menu bar breaks the tab bar. --- content/treestyletab/hacks.js | 42 ++++++++++++++++----- content/treestyletab/treestyletabbrowser.js | 13 +++++++ 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index 5cba579b..1c65f04c 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -1210,33 +1210,57 @@ TreeStyleTabService.overrideExtensionsDelayed = function TSTService_overrideExte // Personal Titlebar // https://addons.mozilla.org/irefox/addon/personal-titlebar/ if (document.getElementById('personal-titlebar')) { + let titlebar = document.getElementById('titlebar'); + let personalTitlebar = document.getElementById('personal-titlebar'); let listener = { handleEvent : function(aEvent) { switch (aEvent.type) { case 'beforecustomization': - let (bar = document.getElementById('personal-titlebar')) { - bar.classList.remove(TreeStyleTabService.kTABBAR_TOOLBAR); - bar.style.top = ''; - bar.style.left = ''; - bar.style.width = ''; - bar.style.height = ''; - bar.removeAttribute('height'); - bar.removeAttribute('width'); - bar.removeAttribute('ordinal'); + titlebar.removeEventListener('DOMAttrModified', this, true); + personalTitlebar.classList.remove(TreeStyleTabService.kTABBAR_TOOLBAR); + personalTitlebar.style.top = ''; + personalTitlebar.style.left = ''; + personalTitlebar.style.width = ''; + personalTitlebar.style.height = ''; + personalTitlebar.removeAttribute('height'); + personalTitlebar.removeAttribute('width'); + personalTitlebar.removeAttribute('ordinal'); + break; + + case 'aftercustomization': + titlebar.addEventListener('DOMAttrModified', this, true); + break; + + case 'DOMAttrModified': + if ( + aEvent.attrName == 'hidden' && + gBrowser.tabContainer.parentNode.id == (aEvent.newValue == 'true' ? 'toolbar-menubar' : 'personal-titlebar' ) + ) { + TreeStyleTabService.stopRendering(); + gBrowser.treeStyleTab.syncDestroyTabbar(); + window.setTimeout(function() { + gBrowser.treeStyleTab.syncReinitTabbar(); + TreeStyleTabService.startRendering(); + }, 0); } break; case 'unload': + titlebar.removeEventListener('DOMAttrModified', this, true); window.removeEventListener('beforecustomization', this, false); + window.removeEventListener('aftercustomization', this, false); window.removeEventListener('unload', this, false); + personalTitlebar = null; break; } } }; window.addEventListener('beforecustomization', listener, false); + window.addEventListener('aftercustomization', listener, false); window.addEventListener('unload', listener, false); + titlebar.addEventListener('DOMAttrModified', listener, true); } // Firefox Sync (Weave) diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 18656f40..22fd679f 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1577,6 +1577,8 @@ TreeStyleTabBrowser.prototype = { syncReinitTabbar : function TSTBrowser_syncReinitTabbar() { + this.stopRendering(); + this.mTabBrowser.mTabContainer.parentNode.classList.add(this.kTABBAR_TOOLBAR); var position = this._lastTabbarPositionBeforeDestroyed || this.position; @@ -1594,6 +1596,8 @@ TreeStyleTabBrowser.prototype = { this.reinitAllTabs(true); this.tabbarDNDObserver.startListenEvents(); + + this.startRendering(); }, destroy : function TSTBrowser_destroy() @@ -1697,6 +1701,8 @@ TreeStyleTabBrowser.prototype = { syncDestroyTabbar : function TSTBrowser_syncDestroyTabbar() { + this.stopRendering(); + this._lastTabbarPositionBeforeDestroyed = this.position; if (this.position != 'top') { let self = this; @@ -1712,6 +1718,11 @@ TreeStyleTabBrowser.prototype = { if (!this.fixed) this.fixed = true; + var tabbar = this.mTabBrowser.tabContainer; + tabbar.removeAttribute('width'); + tabbar.removeAttribute('height'); + tabbar.removeAttribute('ordinal'); + this.removeTabStripAttribute('width'); this.removeTabStripAttribute('height'); this.removeTabStripAttribute('ordinal'); @@ -1721,6 +1732,8 @@ TreeStyleTabBrowser.prototype = { this.tabbarDNDObserver.endListenEvents(); this.mTabBrowser.mTabContainer.parentNode.classList.remove(this.kTABBAR_TOOLBAR); + + this.startRendering(); }, saveCurrentState : function TSTBrowser_saveCurrentState()