From ee4344164e6eb02c3c359d6570c5dd402bc8fc76 Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Tue, 7 Dec 2010 13:46:38 +0900 Subject: [PATCH] less eval: don't overwrite _positionPinnedTabs() --- content/treestyletab/treestyletab.css | 4 ++ content/treestyletab/treestyletabbrowser.js | 53 ++++++++++----------- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/content/treestyletab/treestyletab.css b/content/treestyletab/treestyletab.css index c55fa9d9..86c0ce2d 100644 --- a/content/treestyletab/treestyletab.css +++ b/content/treestyletab/treestyletab.css @@ -335,6 +335,10 @@ tabbrowser[treestyletab-tabbar-autohide-mode="1"][treestyletab-tabbar-autohide=" } /* pinned tabs on Firefox 4.0 */ +.tabbrowser-tabs[treestyletab-mode="vertical"] { + -moz-margin-start: 0 !important; +} + .tabbrowser-tabs[treestyletab-mode="vertical"] .tabbrowser-tab[pinned="true"] { position: fixed !important; diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index b7c6fd3e..20b0ac3d 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -201,15 +201,21 @@ TreeStyleTabBrowser.prototype = { positionPinnedTabs : function TSTBrowser_positionPinnedTabs(aWidth, aHeight) { - if (!this.isVertical) - return; - var b = this.mTabBrowser; var tabbar = b.tabContainer; + if (!tabbar || !tabbar._positionPinnedTabs) + return; + + if (!this.isVertical) { + this.resetPinnedTabs(); + b.mTabContainer._positionPinnedTabs(); + return; + } + var count = this.pinnedTabsCount; var width = aWidth || this.PINNED_TAB_DEFAULT_WIDTH; var height = aHeight || this.PINNED_TAB_DEFAULT_HEIGHT; - var maxCol = Math.floor(tabbar.boxObject.width / width); + var maxCol = Math.floor(this.tabStrip.boxObject.width / width); var maxRow = Math.ceil(count / maxCol); var col = 0; var row = 0; @@ -229,6 +235,12 @@ TreeStyleTabBrowser.prototype = { } } }, + positionPinnedTabsWithDelay : function TSTBrowser_positionPinnedTabsWithDelay() + { + window.setTimeout(function(aSelf) { + aSelf.positionPinnedTabs(); + }, 0, this); + }, PINNED_TAB_DEFAULT_WIDTH : 24, PINNED_TAB_DEFAULT_HEIGHT : 24, @@ -264,13 +276,16 @@ TreeStyleTabBrowser.prototype = { this.partTab(aTab); this.collapseExpandTab(aTab, false); + if (this.isVertical) this.positionPinnedTabs(); }, onUnpinTab : function TSTBrowser_onUnpinTab(aTab) { aTab.style.marginLeft = ''; aTab.style.marginTop = ''; + this.updateInvertedTabContentsOrder(aTab); + if (this.isVertical) this.positionPinnedTabs(); }, updateTabsZIndex : function TSTBrowser_updateTabsZIndex(aStacked) @@ -423,24 +438,6 @@ TreeStyleTabBrowser.prototype = { ) ); - if (b.mTabContainer._positionPinnedTabs) { - eval('b.mTabContainer._positionPinnedTabs = '+ - b.mTabContainer._positionPinnedTabs.toSource().replace( - '{', - .toString() - ).replace( - 'this.mTabstrip.ensureElementIsVisible', - '} $&' - ) - ); - } - TreeStyleTabService.updateTabDNDObserver(b); if (b.tabContainer && '_getDropIndex' in b.tabContainer) { // Firefox 4.0 or later @@ -1157,9 +1154,6 @@ TreeStyleTabBrowser.prototype = { window.setTimeout(function(aSelf) { aSelf.updateFloatingTabbar(aSelf.kTABBAR_UPDATE_BY_APPEARANCE_CHANGE); aSelf.startRendering(); - - if ('_positionPinnedTabs' in b.mTabContainer) - b.mTabContainer._positionPinnedTabs(); }, 0, this); this.allowSubtreeCollapseExpand = this.getTreePref('allowSubtreeCollapseExpand.'+orient) ; @@ -1285,8 +1279,7 @@ TreeStyleTabBrowser.prototype = { this.mTabBrowser.tabContainer.removeAttribute('context'); } - if ('_positionPinnedTabs' in this.mTabBrowser.mTabContainer) - this.mTabBrowser.mTabContainer._positionPinnedTabs(); + this.positionPinnedTabs(); }, updateFloatingTabbarResizer : function TSTBrowser_updateFloatingTabbarResizer(aSize) { @@ -2216,6 +2209,9 @@ TreeStyleTabBrowser.prototype = { this.destroyTab(tab); + if (tab.getAttribute('pinned') == 'true') + this.positionPinnedTabsWithDelay(); + if (this.getPref('browser.tabs.autoHide')) this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR); @@ -2321,6 +2317,8 @@ TreeStyleTabBrowser.prototype = { else this.deleteTabValue(old, this.kINSERT_BEFORE); + this.positionPinnedTabsWithDelay(); + if (this.canStackTabs) this.updateTabsZIndex(true); @@ -3052,6 +3050,7 @@ TreeStyleTabBrowser.prototype = { var horizontal = tabs.orient == 'horizontal'; if (horizontal) return; aEvent.stopPropagation(); + this.positionPinnedTabsWithDelay(); if (aEvent.detail == 1) return; if (aEvent.type == 'overflow') { tabs.setAttribute('overflow', 'true');