起動時のエラーをとりあえず出ないようにした

TODO:
 * ドラッグ&ドロップ関係の処理が全く動いていない
 * onTabBarDblClickも乗っ取れていない

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6410 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-03-23 17:58:23 +00:00
parent 2cb8c9d386
commit bf892a0b1d
3 changed files with 158 additions and 124 deletions

View File

@ -343,6 +343,10 @@ var TreeStyleTabService = {
updateTabDNDObserver : function TSTService_updateTabDNDObserver(aObserver)
{
if (aObserver.tabContainer &&
aObserver.tabContainer.tabbrowser == aObserver)
aObserver = aObserver.tabContainer;
if ('_onDragStart' in aObserver) { // Firefox 3.5 or later
eval('aObserver._onDragStart = '+
aObserver._onDragStart.toSource().replace(
@ -355,7 +359,7 @@ var TreeStyleTabService = {
)
);
}
else { // Firefox 3.0.x
else if ('onDragStart' in aObserver) { // Firefox 3.0.x
eval('aObserver.onDragStart = '+
aObserver.onDragStart.toSource().replace( // native
'aEvent.target.localName == "tab"',
@ -372,6 +376,7 @@ var TreeStyleTabService = {
var canDropFunctionName = '_setEffectAllowedForDataTransfer' in aObserver ?
'_setEffectAllowedForDataTransfer' : // Firefox 3.5 or later
'canDrop' ; // Firefox 3.0.x
if (canDropFunctionName in aObserver) {
eval('aObserver.'+canDropFunctionName+' = '+
aObserver[canDropFunctionName].toSource().replace(
'{',
@ -396,10 +401,12 @@ var TreeStyleTabService = {
)
)
);
}
var dragOverFunctionName = '_onDragOver' in aObserver ?
'_onDragOver' : // Firefox 3.5 or later
'onDragOver' ; // Firefox 3.0.x
if (dragOverFunctionName in aObserver) {
eval('aObserver.'+dragOverFunctionName+' = '+
aObserver[dragOverFunctionName].toSource().replace(
'{',
@ -411,20 +418,24 @@ var TreeStyleTabService = {
]]>
)
);
}
var dragExitFunctionName = '_onDragLeave' in aObserver ?
'_onDragLeave' : // Firefox 3.5 or later
'onDragExit' ; // Firefox 3.0.x
if (dragExitFunctionName in aObserver) {
eval('aObserver.'+dragExitFunctionName+' = '+
aObserver[dragExitFunctionName].toSource().replace(
/(this.mTabDropIndicatorBar\.[^;]+;)/,
'$1; this.treeStyleTab.clearDropPosition();'
)
);
}
var dropFunctionName = '_onDrop' in aObserver ?
'_onDrop' : // Firefox 3.5 or later
'onDrop' ; // Firefox 3.0.x
if (dropFunctionName in aObserver) {
eval('aObserver.'+dropFunctionName+' = '+
aObserver[dropFunctionName].toSource().replace(
'{',
@ -488,6 +499,7 @@ var TreeStyleTabService = {
)
)
);
}
},
onTabbarDragStart : function TSTService_onTabbarDragStart(aEvent, aTabBrowser)
{

View File

@ -158,6 +158,7 @@ TreeStyleTabBrowser.prototype = {
this.stopRendering();
var b = this.mTabBrowser;
b.tabContainer.treeStyleTab = this;
this._tabsCache = {};
@ -171,7 +172,7 @@ TreeStyleTabBrowser.prototype = {
if (!toggler) {
toggler = document.createElement('spacer');
toggler.setAttribute('class', this.kTABBAR_TOGGLER);
this.tabStrip.parentNode.insertBefore(toggler, this.tabStrip);
b.mTabBox.insertBefore(toggler, b.mTabBox.firstChild);
}
}
@ -350,6 +351,16 @@ TreeStyleTabBrowser.prototype = {
this.updateTabDNDObserver(b);
if (b.tabContainer && '_getDropIndex' in b.tabContainer) { // Firefox 3.7 or later
eval('b.tabContainer._getDropIndex = '+
b.tabContainer._getDropIndex.toSource().replace(
/\.screenX/g, '[this.treeStyleTab.positionProp]'
).replace(
/\.width/g, '[this.treeStyleTab.sizeProp]'
)
);
}
else if ('getNewIndex' in b) { // Firefox 3.6 or older
eval('b.getNewIndex = '+
b.getNewIndex.toSource().replace(
/\.screenX/g, '[this.treeStyleTab.positionProp]'
@ -357,6 +368,7 @@ TreeStyleTabBrowser.prototype = {
/\.width/g, '[this.treeStyleTab.sizeProp]'
)
);
}
eval('b.moveTabForward = '+
b.moveTabForward.toSource().replace(
@ -416,6 +428,7 @@ TreeStyleTabBrowser.prototype = {
)
);
/*
if ('' in b) { // Firefox 3.7-
eval('b._handleKeyEvent = '+
b._handleKeyEvent.toSource().replace(
@ -445,7 +458,7 @@ TreeStyleTabBrowser.prototype = {
)
);
}
else if ('_keyEventHandler' in b) { // -Firefox 3.6
else */if ('_keyEventHandler' in b) { // Firefox 3.6 or older
eval('b._keyEventHandler.handleEvent = '+
b._keyEventHandler.handleEvent.toSource().replace(
'this.tabbrowser.moveTabOver(aEvent);',
@ -510,12 +523,14 @@ TreeStyleTabBrowser.prototype = {
)
);
if ('onTabBarDblClick' in b) { // Firefox 3.6 or older
eval('b.onTabBarDblClick = '+
b.onTabBarDblClick.toSource().replace(
'aEvent.originalTarget.localName == "box"',
'/^(box|(arrow)?scrollbox|tabs)$/.test(aEvent.originalTarget.localName)'
)
);
}
if ('_onDragEnd' in b) {
eval('b._onDragEnd = '+b._onDragEnd.toSource().replace(
@ -569,7 +584,8 @@ TreeStyleTabBrowser.prototype = {
this.onPrefChange('extensions.treestyletab.tabbar.invertTabContents');
this.onPrefChange('extensions.treestyletab.tabbar.invertClosebox');
var tabContextMenu = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu');
var tabContextMenu = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu') ||
document.getAnonymousElementByAttribute(b.tabContainer, 'anonid', 'tabContextMenu');
tabContextMenu.addEventListener('popupshowing', this, false);
if (!('MultipleTabService' in window)) {
window.setTimeout(function(aSelf, aTabBrowser, aPopup) {
@ -855,6 +871,7 @@ TreeStyleTabBrowser.prototype = {
var strip = this.tabStrip;
var splitter = this._ensureNewSplitter();
var toggler = document.getAnonymousElementByAttribute(b, 'class', this.kTABBAR_TOGGLER);
var indicator = b.mTabDropIndicatorBar || b.tabContainer._tabDropIndicator;
// Tab Mix Plus
var scrollFrame, newTabBox, tabBarMode;
@ -939,7 +956,7 @@ TreeStyleTabBrowser.prototype = {
unexpectedly becomes 0 on the startup. so, we have
to set the width again. */
strip.setAttribute('width', aSelf.getTreePref('tabbar.width'));
aTabBrowser.mTabDropIndicatorBar.setAttribute('ordinal', 1);
indicator.setAttribute('ordinal', 1);
strip.setAttribute('ordinal', 30);
aSplitter.setAttribute('ordinal', 20);
aToggler.setAttribute('ordinal', 40);
@ -952,7 +969,7 @@ TreeStyleTabBrowser.prototype = {
this.setTabbarAttribute(this.kTAB_INVERTED, null, b);
this.indentTarget = 'left';
delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) {
aTabBrowser.mTabDropIndicatorBar.setAttribute('ordinal', 1);
indicator.setAttribute('ordinal', 1);
strip.setAttribute('ordinal', 10);
aSplitter.setAttribute('ordinal', 20);
aToggler.setAttribute('ordinal', 5);
@ -998,7 +1015,7 @@ TreeStyleTabBrowser.prototype = {
this.setTabbarAttribute(this.kTABBAR_POSITION, 'bottom', b);
this.indentTarget = 'bottom';
delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) {
aTabBrowser.mTabDropIndicatorBar.setAttribute('ordinal', 1);
indicator.setAttribute('ordinal', 1);
strip.setAttribute('ordinal', 30);
aSplitter.setAttribute('ordinal', 20);
aToggler.setAttribute('ordinal', 40);
@ -1009,7 +1026,7 @@ TreeStyleTabBrowser.prototype = {
this.setTabbarAttribute(this.kTABBAR_POSITION, 'top', b);
this.indentTarget = 'top';
delayedPostProcess = function(aSelf, aTabBrowser, aSplitter, aToggler) {
aTabBrowser.mTabDropIndicatorBar.setAttribute('ordinal', 1);
indicator.setAttribute('ordinal', 1);
strip.setAttribute('ordinal', 10);
aSplitter.setAttribute('ordinal', 20);
aToggler.setAttribute('ordinal', 5);
@ -1158,6 +1175,7 @@ TreeStyleTabBrowser.prototype = {
delete this._autoHide;
var b = this.mTabBrowser;
delete b.tabContainer.treeStyleTab;
this.getTabsArray(b).forEach(function(aTab) {
this.destroyTab(aTab);

View File

@ -789,14 +789,18 @@ var TreeStyleTabUtils = {
getTabBrowserFromChild : function TSTUtils_getTabBrowserFromChild(aTabBrowserChild)
{
if (!aTabBrowserChild) return null;
if (!aTabBrowserChild)
return null;
if (aTabBrowserChild.__treestyletab__linkedTabBrowser)
if (aTabBrowserChild.__treestyletab__linkedTabBrowser) // tab
return aTabBrowserChild.__treestyletab__linkedTabBrowser;
if (aTabBrowserChild.localName == 'tabbrowser')
if (aTabBrowserChild.localName == 'tabbrowser') // itself
return aTabBrowserChild;
if (aTabBrowserChild.tabbrowser) // tabs, Firefox 3.7 or later
return aTabBrowserChild.tabbrowser;
var b = this.evaluateXPath(
'ancestor::xul:tabbrowser | '+
'ancestor::xul:tabs[@tabbrowser]',