タブバーの位置をウィンドウごとに変えられるようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6665 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-05-08 05:37:41 +00:00
parent aa93d5e250
commit c2a9430084
7 changed files with 66 additions and 32 deletions

View File

@ -208,7 +208,7 @@ TreeStyleTabService.overrideExtensionsPreInit = function TSTService_overrideExte
if (!(aFunc in window)) return;
eval('window.'+aFunc+' = '+window[aFunc].toSource().replace(
/FS_data.mTabs.(removeAttribute\("moz-collapsed"\)|setAttribute\("moz-collapsed", "true"\));/g,
'if (gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION) == "top") { $& }'
'if (gBrowser.treeStyleTab.currentTabbarPosition == "top") { $& }'
));
}, this);
}
@ -879,7 +879,7 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_override
if (!aEvent.shown) {
if (
autoHIDE.statBar &&
gBrowser.getAttribute(gBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' &&
gBrowser.treeStyleTab.currentTabbarPosition == 'bottom' &&
!gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') &&
gBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar')
) {
@ -890,7 +890,7 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_override
TreeStyleTabService.getTabStrip(gBrowser).removeAttribute('ahHIDE');
if (
autoHIDE.statBar &&
aTabBrowser.getAttribute(gBrowser.treeStyleTab.kTABBAR_POSITION) == 'bottom' &&
aTabBrowser.treeStyleTab.currentTabbarPosition == 'bottom' &&
!aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar.always') &&
aTabBrowser.treeStyleTab.getPref('extensions.autohide.bars.statBar')
) {
@ -901,7 +901,7 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function TSTService_override
case 'fullscreen':
var treeStyleTab = gBrowser.treeStyleTab;
if (gBrowser.getAttribute(treeStyleTab.kTABBAR_POSITION) != 'top') {
if (gBrowser.treeStyleTab.currentTabbarPosition != 'top') {
if (window.fullScreen)
treeStyleTab.autoHide.endForFullScreen();
else

View File

@ -9,7 +9,8 @@ var TreeStyleTabService = {
get currentTabbarPosition() /* PUBLIC API */
{
return this.utils.currentTabbarPosition;
return this.browser.getAttribute(this.kTABBAR_POSITION) ||
this.utils.currentTabbarPosition;
},
set currentTabbarPosition(aValue)
{
@ -60,6 +61,12 @@ var TreeStyleTabService = {
{
return this.utils.useTMPSessionAPI = aValue;
},
get browser()
{
return 'SplitBrowser' in window ? window.SplitBrowser.activeBrowser :
window.gBrowser ;
},
/* backward compatibility */
getTempTreeStyleTab : function TSTService_getTempTreeStyleTab(aTabBrowser)
@ -698,7 +705,7 @@ try{
);
var indicator = aTabBrowser.mTabDropIndicatorBar || aTabBrowser.tabContainer._tabDropIndicator;
indicator.setAttribute('dragging', (info.position == this.kDROP_ON) ? 'false' : 'true' );
return (info.position == this.kDROP_ON || aTabBrowser.getAttribute(this.kTABBAR_POSITION) != 'top')
return (info.position == this.kDROP_ON || aTabBrowser.treeStyleTab.currentTabbarPosition != 'top')
}
catch(e) {
dump('TreeStyleTabService::onDragOver\n'+e+'\n');
@ -1092,14 +1099,14 @@ catch(e) {
eval('FullScreen._animateUp = '+
FullScreen._animateUp.toSource().replace(
/(gBrowser\.mStrip\.boxObject\.height)/,
'((gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION) != "top") ? 0 : $1)'
'((gBrowser.treeStyleTab.currentTabbarPosition != "top") ? 0 : $1)'
)
);
eval('FullScreen.mouseoverToggle = '+
FullScreen.mouseoverToggle.toSource().replace(
// Firefox 3.7 or later
'allFSToolbars[i].setAttribute("moz-collapsed", !aShow);',
'if (allFSToolbars[i].id != "TabsToolbar" || gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION) == "top") { $& }'
'if (allFSToolbars[i].id != "TabsToolbar" || gBrowser.treeStyleTab.currentTabbarPosition == "top") { $& }'
).replace(
// Firefox 3.7 or later
'this._isChromeCollapsed = !aShow;',
@ -1107,7 +1114,7 @@ catch(e) {
).replace(
// Firefox 3.6 or older
'gBrowser.mStrip.setAttribute("moz-collapsed", !aShow);',
'if (gBrowser.getAttribute(TreeStyleTabService.kTABBAR_POSITION) == "top") { $& }'
'if (gBrowser.treeStyleTab.currentTabbarPosition == "top") { $& }'
)
);
eval('FullScreen.toggle = '+
@ -1115,7 +1122,7 @@ catch(e) {
'{',
<![CDATA[{
var treeStyleTab = gBrowser.treeStyleTab;
if (gBrowser.getAttribute(treeStyleTab.kTABBAR_POSITION) != 'top') {
if (treeStyleTab.currentTabbarPosition != 'top') {
if (window.fullScreen)
treeStyleTab.autoHide.endForFullScreen();
else

View File

@ -187,7 +187,7 @@ TreeStyleTabBrowser.prototype = {
let position = this.currentTabbarPosition;
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', 'top', position); /* PUBLIC API */
this.initTabbar(this.kTABBAR_TOP);
this.initTabbar(null, this.kTABBAR_TOP);
var strip = this.tabStrip;
b.mTabContainer.addEventListener('TabOpen', this, true);
@ -632,7 +632,7 @@ TreeStyleTabBrowser.prototype = {
/* To move up content area on the tab bar, switch tab.
If we don't do it, a gray space appears on the content area
by negative margin of it. */
if (b.getAttribute(this.kTABBAR_POSITION) == 'left' &&
if (this.currentTabbarPosition == 'left' &&
b.getAttribute(this.kSCROLLBAR_INVERTED) == 'true') {
b.removeTab(
b.selectedTab = b.addTab('about:blank')
@ -689,7 +689,7 @@ TreeStyleTabBrowser.prototype = {
initTabAttributes : function TSTBrowser_initTabAttributes(aTab)
{
var pos = this.mTabBrowser.getAttribute(this.kTABBAR_POSITION);
var pos = this.currentTabbarPosition;
if (pos == 'left' || pos == 'right') {
aTab.setAttribute('align', 'stretch');
aTab.removeAttribute('maxwidth');
@ -823,13 +823,13 @@ TreeStyleTabBrowser.prototype = {
}, 0, this);
},
initTabbar : function TSTBrowser_initTabbar(aOldPosition)
initTabbar : function TSTBrowser_initTabbar(aNewPosition, aOldPosition)
{
this.stopRendering();
var b = this.mTabBrowser;
var pos = this.getPositionFlag(this.currentTabbarPosition);
var pos = aNewPosition || this.getPositionFlag(this.currentTabbarPosition);
if (b.getAttribute('id') != 'content' &&
!this.getTreePref('tabbar.position.subbrowser.enabled')) {
pos = this.kTABBAR_TOP;
@ -1408,9 +1408,10 @@ TreeStyleTabBrowser.prototype = {
switch (aPrefName)
{
case 'extensions.treestyletab.tabbar.position':
var oldPosition = b.getAttribute(this.kTABBAR_POSITION);
if (window != this.topBrowserWindow) return;
var oldPosition = this.currentTabbarPosition;
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', oldPosition, value); /* PUBLIC API */
this.initTabbar(this.getPositionFlag(oldPosition));
this.initTabbar(this.getPositionFlag(value), this.getPositionFlag(oldPosition));
tabs.forEach(function(aTab) {
this.initTabAttributes(aTab);
}, this);
@ -1474,6 +1475,7 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.width':
case 'extensions.treestyletab.tabbar.shrunkenWidth':
if (window != this.topBrowserWindow) return;
if (!this.autoHide.isResizing && this.isVertical) {
this.removeTabStripAttribute('width');
this.setTabStripAttribute('width', this.autoHide.widthFromMode);
@ -1483,6 +1485,7 @@ TreeStyleTabBrowser.prototype = {
break;
case 'extensions.treestyletab.tabbar.height':
if (window != this.topBrowserWindow) return;
this._horizontalTabMaxIndentBase = 0;
this.checkTabsIndentOverflow();
break;

View File

@ -81,7 +81,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
case this.kMODE_HIDE:
let offset = this.width + this.splitterWidth;
if (sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION) == 'left') {
if (sv.currentTabbarPosition == 'left') {
offset -= this.togglerSize;
}
return offset;
@ -103,7 +103,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
{
var sv = this.mOwner;
return (
sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION) == 'left' &&
sv.currentTabbarPosition == 'left' &&
this.mode != this.kMODE_DISABLED &&
this.expanded
) ? this.XOffset : 0 ;
@ -112,7 +112,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
{
var sv = this.mOwner;
return (
sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION) == 'top' &&
sv.currentTabbarPosition == 'top' &&
this.mode != this.kMODE_DISABLED &&
this.expanded
) ? this.YOffset : 0 ;
@ -238,7 +238,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
var sv = this.mOwner;
var b = sv.mTabBrowser;
var pos = b.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
var box = b.mCurrentBrowser.boxObject;
var sensitiveArea = this.sensitiveArea;
@ -441,7 +441,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
var sv = this.mOwner;
var b = sv.mTabBrowser;
var pos = b.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
if (this.expanded) { // to be hidden or shrunken
this.onHiding();
@ -484,7 +484,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
{
var sv = this.mOwner;
var b = sv.mTabBrowser;
var pos = b.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
switch (pos)
{
@ -523,7 +523,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
{
var sv = this.mOwner;
var b = sv.mTabBrowser;
var pos = b.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
var box = (sv.tabStripPlaceHolder || sv.tabStrip).boxObject;
@ -577,7 +577,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
redrawContentArea : function TSTAutoHide_redrawContentArea()
{
var sv = this.mOwner;
var pos = sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
try {
var v = sv.mTabBrowser.markupDocumentViewer;
if (this.shouldRedraw) {
@ -632,7 +632,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
this.tabbarCanvas.style.width = (this.tabbarCanvas.width = 1)+'px';
this.tabbarCanvas.style.height = (this.tabbarCanvas.height = 1)+'px';
var pos = sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
var frame = sv.mTabBrowser.contentWindow;
var tabContainerBox = sv.mTabBrowser.mTabContainer.boxObject;
@ -746,7 +746,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
sv.tabStrip :
document.getAnonymousElementByAttribute(sv.mTabBrowser, 'class', sv.kSPLITTER) ;
var pos = sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
var prop = pos == 'left' ? 'right' :
pos == 'right' ? 'left' :
pos == 'top' ? 'bottom' :
@ -792,7 +792,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
{
var sv = this.mOwner;
var b = sv.mTabBrowser;
var pos = b.getAttribute(sv.kTABBAR_POSITION);
var pos = sv.currentTabbarPosition;
var style = this.kTRANSPARENT_STYLE[
Math.max(
this.kTRANSPARENT_NONE,
@ -1068,7 +1068,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
return;
}
var sv = this.mOwner;
switch (sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION))
switch (sv.currentTabbarPosition)
{
case 'left':
sv.container.style.marginRight = '-'+this.XOffset+'px';

View File

@ -54,7 +54,7 @@ TreeStyleTabBrowserTabbarDNDObserver.prototype = {
if (canDrag && !aEvent.shiftKey) {
let insensitiveArea = sv.getTreePref('tabbar.fixed.insensitiveArea');
let box = tabbar.boxObject;
switch (sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION))
switch (sv.currentTabbarPosition)
{
case 'right':
if (aEvent.screenX < box.screenX + insensitiveArea)

View File

@ -19,7 +19,7 @@ TreeStyleTabBrowserTabpanelDNDObserver.prototype = {
var sv = this.mOwner;
var position = this.getDropPosition(aEvent);
if (position != 'center' &&
position != sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION))
position != sv.currentTabbarPosition)
sv.setTabbrowserAttribute(sv.kDROP_POSITION, position);
},
@ -28,7 +28,7 @@ TreeStyleTabBrowserTabpanelDNDObserver.prototype = {
var sv = this.mOwner;
var position = this.getDropPosition(aEvent);
if (position != 'center' &&
position != sv.mTabBrowser.getAttribute(sv.kTABBAR_POSITION)) {
position != sv.currentTabbarPosition) {
if (sv.getTreePref('tabbar.fixed.autoCancelOnDrop') &&
(!aXferData || aXferData.data != sv.kTABBAR_MOVE_FORCE)) {
let orient = (position == 'left' || position == 'right') ? 'vertical' : 'horizontal' ;

View File

@ -316,10 +316,34 @@ var TreeStyleTabUtils = {
},
get browserWindow()
{
return this.topBrowserWindow;
},
get topBrowserWindow()
{
return this.WindowMediator.getMostRecentWindow('navigator:browser');
},
get browserWindows()
{
var windows = [];
var targets = this.WindowMediator.getZOrderDOMWindowEnumerator('navigator:browser', true);
// By the bug 156333, we cannot find windows by their Z order on Linux.
// https://bugzilla.mozilla.org/show_bug.cgi?id=156333
if (!targets.hasMoreElements())
targets = this.WindowMediator.getEnumerator('navigator:browser');
while (targets.hasMoreElements())
{
let target = targets.getNext()
.QueryInterface(Ci.nsIDOMWindowInternal);
windows.push(target);
}
return windows;
},
get browser()
{
var w = this.browserWindow;