タブバーを右に置いている時、起動時に一瞬だけ左にタブバーが見えていたのをごまかすようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6252 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-02-03 13:43:39 +00:00
parent 7a08fb726e
commit f56e18ff23
3 changed files with 121 additions and 25 deletions

View File

@ -6,13 +6,13 @@
// do something
window['piro.sakura.ne.jp'].stopRendering.start();
lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi
lisence: The MIT License, Copyright (c) 2009-2010 SHIMODA "Piro" Hiroshi
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
original:
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/stopRendering.js
*/
(function() {
const currentRevision = 2;
const currentRevision = 4;
if (!('piro.sakura.ne.jp' in window)) window['piro.sakura.ne.jp'] = {};
@ -23,6 +23,12 @@
return;
}
if (loadedRevision &&
'destroy' in window['piro.sakura.ne.jp'].stopRendering)
window['piro.sakura.ne.jp'].stopRendering.destroy();
const Ci = Components.interfaces;
window['piro.sakura.ne.jp'].stopRendering = {
revision : currentRevision,
@ -31,27 +37,93 @@
get baswWindow()
{
return window.top
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell)
.QueryInterface(Components.interfaces.nsIBaseWindow);
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.QueryInterface(Ci.nsIBaseWindow);
},
stop : function()
{
if (!this._stopLevel) {
this.baswWindow.setPosition(window.top.innerWidth * 3, window.top.innerHeight * 3);
}
this._stopLevel++;
},
start : function()
{
this._stopLevel--;
if (!this._stopLevel) {
if (this._stopLevel > 0)
return;
this._stopLevel = 0;
this.baswWindow.setPosition(0, 0);
this._popups.forEach(function(aPopup, aIndex) {
if (aPopup.state != 'open') return;
var w = aPopup.boxObject.width;
var h = aPopup.boxObject.height;
aPopup.sizeTo(w, h-1);
aPopup.sizeTo(w, h);
}, this);
},
onResize : function(aEvent)
{
if (aEvent.target != window || !this._stopLevel)
return;
this._stopLevel = 0;
this.start();
},
handleEvent : function(aEvent)
{
switch (aEvent.type)
{
case 'unload':
this.destroy();
return;
case 'resize':
this.onResize(aEvent);
return;
case 'popupshown':
let (index = this._popups.indexOf(aEvent.originalTarget)) {
if (index < 0)
this._popups.push(aEvent.originalTarget);
}
return;
case 'popuphidden':
let (index = this._popups.indexOf(aEvent.originalTarget)) {
if (index > -1)
this._popups.splice(index, 1);
}
return;
}
},
init : function()
{
this._popups = [];
window.addEventListener('resize', this, false);
window.addEventListener('popupshown', this, false);
window.addEventListener('popuphidden', this, false);
window.addEventListener('unload', this, false);
},
destroy : function()
{
this._popups = [];
window.removeEventListener('resize', this, false);
window.removeEventListener('popupshown', this, false);
window.removeEventListener('popuphidden', this, false);
window.removeEventListener('unload', this, false);
}
};
window['piro.sakura.ne.jp'].stopRendering.init();
})();

View File

@ -132,6 +132,8 @@ TreeStyleTabBrowser.prototype = {
init : function TSTBrowser_init()
{
this.stopRendering();
var b = this.mTabBrowser;
this.internallyTabMovingCount = 0;
@ -151,7 +153,7 @@ TreeStyleTabBrowser.prototype = {
let position = this.currentTabbarPosition;
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', 'top', position); /* PUBLIC API */
this.initTabbar();
this.initTabbar(this.kTABBAR_TOP);
b.addEventListener('TabOpen', this, true);
b.addEventListener('TabClose', this, true);
@ -591,6 +593,8 @@ TreeStyleTabBrowser.prototype = {
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanged', 'top', position); /* PUBLIC API */
b = null;
this.startRendering();
},
initTab : function TSTBrowser_initTab(aTab)
@ -758,24 +762,33 @@ TreeStyleTabBrowser.prototype = {
}, 0, this);
},
initTabbar : function TSTBrowser_initTabbar(aPosition)
initTabbar : function TSTBrowser_initTabbar(aOldPosition)
{
this.stopRendering();
var b = this.mTabBrowser;
if (!aPosition) aPosition = this.currentTabbarPosition;
aPosition = String(aPosition).toLowerCase();
var pos = this.getPositionFlag(this.currentTabbarPosition);
if (b.getAttribute('id') != 'content' &&
!this.getTreePref('tabbar.position.subbrowser.enabled')) {
aPosition = 'top';
pos = this.kTABBAR_TOP;
}
var pos = (aPosition == 'left') ? this.kTABBAR_LEFT :
(aPosition == 'right') ? this.kTABBAR_RIGHT :
(aPosition == 'bottom') ? this.kTABBAR_BOTTOM :
this.kTABBAR_TOP;
aOldPosition = aOldPosition || pos;
// We have to use CSS property hack instead, because the stopRendering()
// doesn't effect on the first time of startup.
// * This hack works in a "stop"-"start" pair, so, people never see the side effect.
// * This hack works only when "ordinal" properties are modified.
// So, this is just for the case: "right" or "bottom" tab bar on the startup.
if (
pos != aOldPosition &&
(
((pos & this.kTABBAR_REGULAR) && (aOldPosition & this.kTABBAR_INVERTED)) ||
((pos & this.kTABBAR_INVERTED) && (aOldPosition & this.kTABBAR_REGULAR))
)
)
b.style.visibility = 'hidden';
var splitter = this._ensureNewSplitter();
var toggler = document.getAnonymousElementByAttribute(b, 'class', this.kTABBAR_TOGGLER);
@ -953,6 +966,8 @@ TreeStyleTabBrowser.prototype = {
delayedPostProcess(aSelf, aTabBrowser, aSplitter, aToggler);
aSelf.updateTabbarOverflow();
delayedPostProcess = null;
aSelf.mTabBrowser.style.visibility = '';
aSelf.startRendering();
}, 0, this, b, splitter, toggler);
b = null;
@ -966,8 +981,6 @@ TreeStyleTabBrowser.prototype = {
scrollInnerBox = null;
scrollInnerBox = null;
allTabsButton = null;
this.startRendering();
},
_ensureNewSplitter : function TSTBrowser__ensureNewSplitter()
@ -1203,7 +1216,7 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.position':
var oldPosition = b.getAttribute(this.kTABBAR_POSITION);
this.fireTabbarPositionEvent('TreeStyleTabTabbarPositionChanging', oldPosition, value); /* PUBLIC API */
this.initTabbar();
this.initTabbar(this.getPositionFlag(oldPosition));
tabs.forEach(function(aTab) {
this.initTabAttributes(aTab);
}, this);

View File

@ -14,7 +14,7 @@
* The Original Code is the Tree Style Tab.
*
* The Initial Developer of the Original Code is SHIMODA Hiroshi.
* Portions created by the Initial Developer are Copyright (C) 2009
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): SHIMODA Hiroshi <piro@p.club.ne.jp>
@ -134,6 +134,8 @@ var TreeStyleTabUtils = {
kTABBAR_HORIZONTAL : (1 << 0) | (1 << 1),
kTABBAR_VERTICAL : (1 << 2) | (1 << 3),
kTABBAR_REGULAR : (1 << 0) | (1 << 2),
kTABBAR_INVERTED : (1 << 3) | (1 << 4),
kINSERT_FISRT : 0,
kINSERT_LAST : 1,
@ -1481,6 +1483,15 @@ var TreeStyleTabUtils = {
return aValue;
},
getPositionFlag : function TSTUtils_getPositionFlag(aPosition)
{
aPosition = String(aPosition).toLowerCase();
return (aPosition == 'left') ? this.kTABBAR_LEFT :
(aPosition == 'right') ? this.kTABBAR_RIGHT :
(aPosition == 'bottom') ? this.kTABBAR_BOTTOM :
this.kTABBAR_TOP;
},
/* Pref Listener */
domains : [