From b47cbe6a8b135b2cbd21971e7fa7db3c6339a842 Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 27 Apr 2009 06:41:26 +0000 Subject: [PATCH] =?UTF-8?q?AutoHide=201.5.4=EF=BC=88=20http://www.krickelk?= =?UTF-8?q?rackel.de/autohide/=20=EF=BC=89=E3=81=A8=E3=81=AE=E7=AB=B6?= =?UTF-8?q?=E5=90=88=E3=82=92=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4187 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/hacks.js | 201 ++++++-------------- content/treestyletab/treestyletab.js | 20 +- content/treestyletab/treestyletabbrowser.js | 28 +++ 3 files changed, 95 insertions(+), 154 deletions(-) diff --git a/content/treestyletab/hacks.js b/content/treestyletab/hacks.js index 5e5813f9..562ae381 100644 --- a/content/treestyletab/hacks.js +++ b/content/treestyletab/hacks.js @@ -162,154 +162,6 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() { ); } - if ('autoHIDE' in window) { // Autohide - var func = 'ShowBars' in autoHIDE ? 'ShowBars' : 'ShowMenu' ; - eval('autoHIDE.'+func+' = '+ - autoHIDE[func].toSource().replace( - '{', - '{ var treeStyleTabPos = gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION);' - ).replace( - /e.screenY <= ((autoHIDE|ah).Win.boxObject).screenY \+ (autoHIDE.space|ah.senseArea)/, - = $1.screenX + $1.width - $3) : - treeStyleTabPos == 'bottom' ? - (e.screenY >= $1.screenY + $1.height - $3) : - false - ))]]> - ).replace( // for old version - 'e.screenY > getBrowser().mCurrentBrowser.boxObject.screenY + 25', - gBrowser.mCurrentBrowser.boxObject.screenY + 25 && - ( - treeStyleTabPos == 'left' ? - (e.screenX > gBrowser.mCurrentBrowser.boxObject.screenX + 25) : - treeStyleTabPos == 'right' ? - (e.screenX < gBrowser.mCurrentBrowser.boxObject.screenX + gBrowser.mCurrentBrowser.boxObject.width - 25) : - treeStyleTabPos == 'bottom' ? - (e.screenY < gBrowser.mCurrentBrowser.boxObject.screenY + gBrowser.mCurrentBrowser.boxObject.height - 25) : - true - ))]]> - ).replace( // for new version - 'e.screenY > yCondition', - yCondition && - ( - treeStyleTabPos == 'left' ? - (e.screenX > gBrowser.mCurrentBrowser.boxObject.screenX + 50) : - treeStyleTabPos == 'right' ? - (e.screenX < gBrowser.mCurrentBrowser.boxObject.screenX + gBrowser.mCurrentBrowser.boxObject.width - 50) : - treeStyleTabPos == 'bottom' ? - (e.screenY < gBrowser.mCurrentBrowser.boxObject.screenY + gBrowser.mCurrentBrowser.boxObject.height - 50) : - true - ))]]> - ) - ); - eval('autoHIDE.HideToolbar = '+ - autoHIDE.HideToolbar.toSource().replace( - /if \(((this|ah).Show)\) \{/, - - ) - ); - func = 'RemoveAttrib' in autoHIDE ? 'RemoveAttrib' : 'EndFull' ; - eval('autoHIDE.'+func+' = '+ - autoHIDE[func].toSource().replace( - '{', - - ) - ); - eval('autoHIDE.SetMenu = '+ - autoHIDE.SetMenu.toSource().replace( - '{', - - ) - ); - func = 'MoveContent' in autoHIDE ? 'MoveContent' : 'MoveC' ; - eval('autoHIDE.'+func+' = '+ - autoHIDE[func].toSource().replace( - '{', - - ).replace( - /.(move|setPosition)\(0, - (this|ah).delta\)/, - - ) - ); - var autoHideEventListener = { - handleEvent : function(aEvent) - { - switch (aEvent.type) - { - case 'fullscreen': - var autoHide = TreeStyleTabService.getTreePref('tabbar.autoHide.enabled'); - var pos = gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION); - if (window.fullScreen) { // restore - if (autoHide && (pos == 'left' || pos == 'right')) - gBrowser.treeStyleTab.startAutoHide(); - } - else { // turn to fullscreen - gBrowser.treeStyleTab.endAutoHide(); - } - break; - - case 'unload': - var t = aEvent.currentTarget; - t.removeEventListener('unload', this, false); - t.removeEventListener('fullscreen', this, false); - break; - } - } - }; - window.addEventListener('fullscreen', autoHideEventListener, false); - window.addEventListener('unload', autoHideEventListener, false); - } - // Tab Mix Plus if ('TMupdateSettings' in window) { @@ -820,4 +672,57 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() { ); } + + // Autohide + if ('autoHIDE' in window) { + TreeStyleTabService.registerTabbarAutoShowPostProcess(function(aTabBrowser) { + if (!window.fullScreen) return; + aTabBrowser.mStrip.removeAttribute('ahHIDE'); + if ( + autoHIDE.statBar && + aTabBrowser.getAttribute(aTabBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' && + !aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') && + aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar') + ) { + autoHIDE.statBar.removeAttribute('ahHIDE'); + } + }); + TreeStyleTabService.registerTabbarAutoHidePostProcess(function(aTabBrowser) { + if (!window.fullScreen) return; + if ( + autoHIDE.statBar && + aTabBrowser.getAttribute(aTabBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' && + !aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') && + aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar') + ) { + autoHIDE.statBar.setAttribute('ahHIDE', true); + } + }); + var autoHideEventListener = { + handleEvent : function(aEvent) + { + switch (aEvent.type) + { + case 'fullscreen': + var treeStyleTab = gBrowser.treeStyleTab; + if (gBrowser.getAttribute(treeStyleTab.kTABBAR_POSITION) != 'top') { + if (window.fullScreen) + treeStyleTab.endAutoHideForFullScreen(); + else + treeStyleTab.startAutoHideForFullScreen(); + } + break; + + case 'unload': + var t = aEvent.currentTarget; + t.removeEventListener('unload', this, false); + t.removeEventListener('fullscreen', this, false); + break; + } + } + }; + window.addEventListener('fullscreen', autoHideEventListener, false); + window.addEventListener('unload', autoHideEventListener, false); + } + }; diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 7093e9a3..b454ace9 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1580,13 +1580,10 @@ catch(e) { ) @@ -2132,6 +2129,17 @@ catch(e) { }, _collapseExpandPostProcess : [], + registerTabbarAutoShowPostProcess : function(aProcess) + { + this._tabbarAutoShowPostProcess.push(aProcess); + }, + registerTabbarAutoHidePostProcess : function(aProcess) + { + this._tabbarAutoHidePostProcess.push(aProcess); + }, + _tabbarAutoShowPostProcess : [], + _tabbarAutoHidePostProcess : [], + tearOffSubTreeFromRemote : function() { var remoteTab = window.arguments[0]; diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 170f1ddb..e0c1b778 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -3537,6 +3537,9 @@ TreeStyleTabBrowser.prototype = { } this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN; this.autoHideShown = false; + this._tabbarAutoHidePostProcess.every(function(aFunc) { + return aFunc(b); + }); } else { // to be shown or expanded switch (b.getAttribute(this.kTABBAR_POSITION)) @@ -3568,6 +3571,9 @@ TreeStyleTabBrowser.prototype = { } this.showHideTabbarReason = aReason || this.kSHOWN_BY_UNKNOWN; this.autoHideShown = true; + this._tabbarAutoShowPostProcess.every(function(aFunc) { + return aFunc(b); + }); } window.setTimeout(function(aSelf) { if ( @@ -3852,6 +3858,28 @@ TreeStyleTabBrowser.prototype = { this.tabbarExpanded = true; }, + startAutoHideForFullScreen : function() + { + this.autoHideMode = this.getTreePref('tabbar.autoHide.mode'); + this.endAutoHide(); + this.autoHideMode = this.getTreePref('tabbar.autoHide.mode.fullscreen'); + if (this.autoHideMode != this.kAUTOHIDE_MODE_DISABLED) { + this.startAutoHide(); + this.mTabBrowser.mStrip.removeAttribute('moz-collapsed'); + this.mTabBrowser.mTabContainer.removeAttribute('moz-collapsed'); // ”O‚Ì‚½‚ß + } + }, + + endAutoHideForFullScreen : function() + { + this.autoHideMode = this.getTreePref('tabbar.autoHide.mode.fullscreen'); + this.endAutoHide(); + this.autoHideMode = this.getTreePref('tabbar.autoHide.mode'); + this.checkTabsIndentOverflow(); + if (this.autoHideMode != this.kAUTOHIDE_MODE_DISABLED) + this.startAutoHide(); + }, + startListenMouseMove : function() { if (this.mouseMoveListening) return;