起動時のエラーをとりあえず出ないようにした
TODO: * ドラッグ&ドロップ関係の処理が全く動いていない * onTabBarDblClickも乗っ取れていない git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6410 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
2cb8c9d386
commit
bf892a0b1d
@ -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,122 +376,130 @@ var TreeStyleTabService = {
|
||||
var canDropFunctionName = '_setEffectAllowedForDataTransfer' in aObserver ?
|
||||
'_setEffectAllowedForDataTransfer' : // Firefox 3.5 or later
|
||||
'canDrop' ; // Firefox 3.0.x
|
||||
eval('aObserver.'+canDropFunctionName+' = '+
|
||||
aObserver[canDropFunctionName].toSource().replace(
|
||||
'{',
|
||||
'{ var TSTTabBrowser = this;'
|
||||
).replace(
|
||||
/\.screenX/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.positionProp]'
|
||||
).replace(
|
||||
/\.width/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.sizeProp]'
|
||||
).replace(
|
||||
/(return (?:true|dt.effectAllowed = "copyMove");)/,
|
||||
<![CDATA[
|
||||
if (!this.treeStyleTab.checkCanTabDrop(aEvent, this)) {
|
||||
return TST_DRAGDROP_DISALLOW_RETRUN_VALUE;
|
||||
}
|
||||
$1
|
||||
]]>
|
||||
).replace(
|
||||
/TST_DRAGDROP_DISALLOW_RETRUN_VALUE/g,
|
||||
(canDropFunctionName == 'canDrop' ?
|
||||
'false' :
|
||||
'dt.effectAllowed = "none"'
|
||||
if (canDropFunctionName in aObserver) {
|
||||
eval('aObserver.'+canDropFunctionName+' = '+
|
||||
aObserver[canDropFunctionName].toSource().replace(
|
||||
'{',
|
||||
'{ var TSTTabBrowser = this;'
|
||||
).replace(
|
||||
/\.screenX/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.positionProp]'
|
||||
).replace(
|
||||
/\.width/g, '[TreeStyleTabService.getTabBrowserFromChild(TSTTabBrowser).treeStyleTab.sizeProp]'
|
||||
).replace(
|
||||
/(return (?:true|dt.effectAllowed = "copyMove");)/,
|
||||
<![CDATA[
|
||||
if (!this.treeStyleTab.checkCanTabDrop(aEvent, this)) {
|
||||
return TST_DRAGDROP_DISALLOW_RETRUN_VALUE;
|
||||
}
|
||||
$1
|
||||
]]>
|
||||
).replace(
|
||||
/TST_DRAGDROP_DISALLOW_RETRUN_VALUE/g,
|
||||
(canDropFunctionName == 'canDrop' ?
|
||||
'false' :
|
||||
'dt.effectAllowed = "none"'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
var dragOverFunctionName = '_onDragOver' in aObserver ?
|
||||
'_onDragOver' : // Firefox 3.5 or later
|
||||
'onDragOver' ; // Firefox 3.0.x
|
||||
eval('aObserver.'+dragOverFunctionName+' = '+
|
||||
aObserver[dragOverFunctionName].toSource().replace(
|
||||
'{',
|
||||
<![CDATA[
|
||||
{
|
||||
if (this.treeStyleTab.processTabDragOverEvent(aEvent, this)) {
|
||||
return;
|
||||
}
|
||||
]]>
|
||||
)
|
||||
);
|
||||
if (dragOverFunctionName in aObserver) {
|
||||
eval('aObserver.'+dragOverFunctionName+' = '+
|
||||
aObserver[dragOverFunctionName].toSource().replace(
|
||||
'{',
|
||||
<![CDATA[
|
||||
{
|
||||
if (this.treeStyleTab.processTabDragOverEvent(aEvent, this)) {
|
||||
return;
|
||||
}
|
||||
]]>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
var dragExitFunctionName = '_onDragLeave' in aObserver ?
|
||||
'_onDragLeave' : // Firefox 3.5 or later
|
||||
'onDragExit' ; // Firefox 3.0.x
|
||||
eval('aObserver.'+dragExitFunctionName+' = '+
|
||||
aObserver[dragExitFunctionName].toSource().replace(
|
||||
/(this.mTabDropIndicatorBar\.[^;]+;)/,
|
||||
'$1; this.treeStyleTab.clearDropPosition();'
|
||||
)
|
||||
);
|
||||
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
|
||||
eval('aObserver.'+dropFunctionName+' = '+
|
||||
aObserver[dropFunctionName].toSource().replace(
|
||||
'{',
|
||||
<![CDATA[
|
||||
{
|
||||
var TSTTabBrowser = this;
|
||||
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
||||
var dropActionInfo = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
||||
]]>
|
||||
).replace( // Firefox 3.0.x, 3.5 or later
|
||||
/(if \((accelKeyPressed|isCopy|dropEffect == "copy")\) {)/,
|
||||
<![CDATA[
|
||||
if (TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, draggedTab))
|
||||
if (dropFunctionName in aObserver) {
|
||||
eval('aObserver.'+dropFunctionName+' = '+
|
||||
aObserver[dropFunctionName].toSource().replace(
|
||||
'{',
|
||||
<![CDATA[
|
||||
{
|
||||
var TSTTabBrowser = this;
|
||||
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
||||
var dropActionInfo = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
||||
]]>
|
||||
).replace( // Firefox 3.0.x, 3.5 or later
|
||||
/(if \((accelKeyPressed|isCopy|dropEffect == "copy")\) {)/,
|
||||
<![CDATA[
|
||||
if (TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, draggedTab))
|
||||
return;
|
||||
$1]]>
|
||||
).replace( // Firefox 3, duplication of tab
|
||||
/(this.selectedTab = newTab;)(\s*\})?/g,
|
||||
<![CDATA[$1;
|
||||
if (dropActionInfo.position == TreeStyleTabService.kDROP_ON)
|
||||
TSTTabBrowser.treeStyleTab.attachTabTo(newTab, dropActionInfo.target);
|
||||
$2]]>
|
||||
).replace( // Firefox 3, dragging tab from another window
|
||||
'else if (draggedTab) {',
|
||||
<![CDATA[$&
|
||||
if (TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, draggedTab))
|
||||
return;
|
||||
]]>
|
||||
).replace(
|
||||
/(this.loadOneTab\([^;]+\));/,
|
||||
<![CDATA[
|
||||
TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, $1);
|
||||
return;
|
||||
$1]]>
|
||||
).replace( // Firefox 3, duplication of tab
|
||||
/(this.selectedTab = newTab;)(\s*\})?/g,
|
||||
<![CDATA[$1;
|
||||
if (dropActionInfo.position == TreeStyleTabService.kDROP_ON)
|
||||
TSTTabBrowser.treeStyleTab.attachTabTo(newTab, dropActionInfo.target);
|
||||
$2]]>
|
||||
).replace( // Firefox 3, dragging tab from another window
|
||||
'else if (draggedTab) {',
|
||||
<![CDATA[$&
|
||||
if (TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, draggedTab))
|
||||
return;
|
||||
]]>
|
||||
).replace(
|
||||
/(this.loadOneTab\([^;]+\));/,
|
||||
<![CDATA[
|
||||
TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, $1);
|
||||
return;
|
||||
]]>
|
||||
).replace(
|
||||
'document.getBindingParent(aEvent.originalTarget).localName != "tab"',
|
||||
'!TreeStyleTabService.getTabFromEvent(aEvent)'
|
||||
).replace(
|
||||
'var tab = aEvent.target;',
|
||||
<![CDATA[$&
|
||||
var loadDroppedLinkToNewChildTab = (
|
||||
dropActionInfo.position != TreeStyleTabService.kDROP_ON ||
|
||||
]]>
|
||||
).replace(
|
||||
'document.getBindingParent(aEvent.originalTarget).localName != "tab"',
|
||||
'!TreeStyleTabService.getTabFromEvent(aEvent)'
|
||||
).replace(
|
||||
'var tab = aEvent.target;',
|
||||
<![CDATA[$&
|
||||
var loadDroppedLinkToNewChildTab = (
|
||||
dropActionInfo.position != TreeStyleTabService.kDROP_ON ||
|
||||
tab.getAttribute('locked') == 'true' // Tab Mix Plus (or others)
|
||||
);
|
||||
if (!loadDroppedLinkToNewChildTab &&
|
||||
dropActionInfo.position == TreeStyleTabService.kDROP_ON) {
|
||||
loadDroppedLinkToNewChildTab = TreeStyleTabService.dropLinksOnTabBehavior() == TreeStyleTabService.kDROPLINK_NEWTAB;
|
||||
}
|
||||
if (
|
||||
loadDroppedLinkToNewChildTab ||
|
||||
tab.getAttribute('locked') == 'true' // Tab Mix Plus (or others)
|
||||
);
|
||||
if (!loadDroppedLinkToNewChildTab &&
|
||||
dropActionInfo.position == TreeStyleTabService.kDROP_ON) {
|
||||
loadDroppedLinkToNewChildTab = TreeStyleTabService.dropLinksOnTabBehavior() == TreeStyleTabService.kDROPLINK_NEWTAB;
|
||||
}
|
||||
if (
|
||||
loadDroppedLinkToNewChildTab ||
|
||||
tab.getAttribute('locked') == 'true' // Tab Mix Plus (or others)
|
||||
) {
|
||||
TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, TSTTabBrowser.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false));
|
||||
return;
|
||||
}
|
||||
]]>
|
||||
).replace(
|
||||
/TST_DRAGSESSION/g,
|
||||
(canDropFunctionName == 'canDrop' ?
|
||||
'aDragSession' :
|
||||
'TSTTabBrowser.treeStyleTab.getCurrentDragSession()'
|
||||
) {
|
||||
TSTTabBrowser.treeStyleTab.performDrop(dropActionInfo, TSTTabBrowser.loadOneTab(getShortcutOrURI(url), null, null, null, bgLoad, false));
|
||||
return;
|
||||
}
|
||||
]]>
|
||||
).replace(
|
||||
/TST_DRAGSESSION/g,
|
||||
(canDropFunctionName == 'canDrop' ?
|
||||
'aDragSession' :
|
||||
'TSTTabBrowser.treeStyleTab.getCurrentDragSession()'
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
}
|
||||
},
|
||||
onTabbarDragStart : function TSTService_onTabbarDragStart(aEvent, aTabBrowser)
|
||||
{
|
||||
|
@ -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,13 +351,24 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
this.updateTabDNDObserver(b);
|
||||
|
||||
eval('b.getNewIndex = '+
|
||||
b.getNewIndex.toSource().replace(
|
||||
/\.screenX/g, '[this.treeStyleTab.positionProp]'
|
||||
).replace(
|
||||
/\.width/g, '[this.treeStyleTab.sizeProp]'
|
||||
)
|
||||
);
|
||||
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]'
|
||||
).replace(
|
||||
/\.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 = {
|
||||
)
|
||||
);
|
||||
|
||||
eval('b.onTabBarDblClick = '+
|
||||
b.onTabBarDblClick.toSource().replace(
|
||||
'aEvent.originalTarget.localName == "box"',
|
||||
'/^(box|(arrow)?scrollbox|tabs)$/.test(aEvent.originalTarget.localName)'
|
||||
)
|
||||
);
|
||||
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);
|
||||
|
@ -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]',
|
||||
|
Loading…
Reference in New Issue
Block a user