サブツリーのウィンドウ外へのドラッグによるサブツリーの別ウィンドウへの切り離しをサポート
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@3412 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
e10c5bca75
commit
cc35a7bf1f
@ -862,6 +862,22 @@ var TreeStyleTabService = {
|
|||||||
|
|
||||||
window.addEventListener('SSTabRestoring', this, true);
|
window.addEventListener('SSTabRestoring', this, true);
|
||||||
|
|
||||||
|
if ('swapBrowsersAndCloseOther' in document.getElementById('content')) {
|
||||||
|
var source = window.BrowserStartup.toSource();
|
||||||
|
if (source.indexOf('!MultipleTabService.tearOffSelectedTabsFromRemote()') > -1) {
|
||||||
|
eval('window.BrowserStartup = '+source.replace(
|
||||||
|
'!MultipleTabService.tearOffSelectedTabsFromRemote()',
|
||||||
|
'!TreeStyleTabService.tearOffSubTreeFromRemote() && $&'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
eval('window.BrowserStartup = '+source.replace(
|
||||||
|
'gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, uriToLoad);',
|
||||||
|
'if (!TreeStyleTabService.tearOffSubTreeFromRemote()) { $& }'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.overrideExtensionsPreInit(); // hacks.js
|
this.overrideExtensionsPreInit(); // hacks.js
|
||||||
},
|
},
|
||||||
preInitialized : false,
|
preInitialized : false,
|
||||||
@ -1915,6 +1931,36 @@ catch(e) {
|
|||||||
this._collapseExpandPostProcess.push(aProcess);
|
this._collapseExpandPostProcess.push(aProcess);
|
||||||
},
|
},
|
||||||
_collapseExpandPostProcess : [],
|
_collapseExpandPostProcess : [],
|
||||||
|
|
||||||
|
tearOffSubTreeFromRemote : function()
|
||||||
|
{
|
||||||
|
var remoteTab = window.arguments[0];
|
||||||
|
var remoteWindow = remoteTab.ownerDocument.defaultView;
|
||||||
|
var remoteService = remoteWindow.TreeStyleTabService;
|
||||||
|
var remoteMultipleTabService = remoteWindow.MultipleTabService;
|
||||||
|
if (remoteService.hasChildTabs(remoteTab) ||
|
||||||
|
remoteMultipleTabService.isSelected(remoteTab)) {
|
||||||
|
var remoteBrowser = remoteService.getTabBrowserFromChild(remoteTab);
|
||||||
|
var actionInfo = {
|
||||||
|
action : this.kACTIONS_FOR_DESTINATION | this.kACTION_IMPORT
|
||||||
|
};
|
||||||
|
var tabsInfo = remoteBrowser.treeStyleTab.getDraggedTabsInfoFromOneTab(actionInfo, remoteTab);
|
||||||
|
if (tabsInfo.draggedTabs.length == remoteBrowser.mTabContainer.childNodes.length) {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.setTimeout(function() {
|
||||||
|
var blankTab = gBrowser.selectedTab;
|
||||||
|
gBrowser.treeStyleTab.performDrop(actionInfo, remoteTab);
|
||||||
|
window.setTimeout(function() {
|
||||||
|
gBrowser.removeTab(blankTab);
|
||||||
|
}, 0);
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
/* Pref Listener */
|
/* Pref Listener */
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
kMENUITEM_FIXED : 'context-item-toggleFixed',
|
kMENUITEM_FIXED : 'context-item-toggleFixed',
|
||||||
kMENUITEM_POSITION : 'context-menu-tabbarPosition',
|
kMENUITEM_POSITION : 'context-menu-tabbarPosition',
|
||||||
kMENUITEM_BOOKMARKSUBTREE : 'context-item-bookmarkTabSubTree',
|
kMENUITEM_BOOKMARKSUBTREE : 'context-item-bookmarkTabSubTree',
|
||||||
|
|
||||||
mTabBrowser : null,
|
mTabBrowser : null,
|
||||||
|
|
||||||
tabbarResizing : false,
|
tabbarResizing : false,
|
||||||
@ -57,7 +57,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
/* utils */
|
/* utils */
|
||||||
|
|
||||||
/* get tab contents */
|
/* get tab contents */
|
||||||
|
|
||||||
getTabLabel : function(aTab)
|
getTabLabel : function(aTab)
|
||||||
{
|
{
|
||||||
var label = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X
|
var label = document.getAnonymousElementByAttribute(aTab, 'class', 'tab-text-stack') || // Mac OS X
|
||||||
@ -100,7 +100,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* initialize */
|
/* initialize */
|
||||||
|
|
||||||
init : function()
|
init : function()
|
||||||
{
|
{
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
@ -484,7 +484,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.ObserverService.addObserver(this, 'TreeStyleTab:collapseExpandAllSubtree', false);
|
this.ObserverService.addObserver(this, 'TreeStyleTab:collapseExpandAllSubtree', false);
|
||||||
this.addPrefListener(this);
|
this.addPrefListener(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
initTab : function(aTab)
|
initTab : function(aTab)
|
||||||
{
|
{
|
||||||
if (!aTab.hasAttribute(this.kID)) {
|
if (!aTab.hasAttribute(this.kID)) {
|
||||||
@ -844,7 +844,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
delete this.mTabBrowser;
|
delete this.mTabBrowser;
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyTab : function(aTab)
|
destroyTab : function(aTab)
|
||||||
{
|
{
|
||||||
delete aTab.__treestyletab__linkedTabBrowser;
|
delete aTab.__treestyletab__linkedTabBrowser;
|
||||||
@ -1858,7 +1858,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
autoExpandTimer : null,
|
autoExpandTimer : null,
|
||||||
autoExpandTarget : null,
|
autoExpandTarget : null,
|
||||||
autoExpandedTabs : [],
|
autoExpandedTabs : [],
|
||||||
|
|
||||||
onDragEnter : function(aEvent, aDragSession)
|
onDragEnter : function(aEvent, aDragSession)
|
||||||
{
|
{
|
||||||
var tab = aEvent.target;
|
var tab = aEvent.target;
|
||||||
@ -2147,45 +2147,17 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
performDrop : function(aInfo, aDraggedTab)
|
performDrop : function(aInfo, aDraggedTab)
|
||||||
{
|
{
|
||||||
aDraggedTab = this.getTabFromChild(aDraggedTab);
|
var tabsInfo = this.getDraggedTabsInfoFromOneTab(aInfo, aDraggedTab);
|
||||||
|
aDraggedTab = tabsInfo.draggedTab;
|
||||||
|
var draggedTabs = tabsInfo.draggedTabs;
|
||||||
|
var draggedRoots = tabsInfo.draggedRoots;
|
||||||
|
|
||||||
var targetBrowser = this.mTabBrowser;
|
var targetBrowser = this.mTabBrowser;
|
||||||
var tabs = targetBrowser.mTabContainer.childNodes;
|
var tabs = targetBrowser.mTabContainer.childNodes;
|
||||||
|
|
||||||
var draggedTabs = [aDraggedTab];
|
|
||||||
var draggedRoots = [aDraggedTab];
|
|
||||||
|
|
||||||
var sourceWindow = aDraggedTab.ownerDocument.defaultView;
|
var sourceWindow = aDraggedTab.ownerDocument.defaultView;
|
||||||
var sourceBrowser = this.getTabBrowserFromChild(aDraggedTab);
|
var sourceBrowser = this.getTabBrowserFromChild(aDraggedTab);
|
||||||
|
|
||||||
var isSelectionMove = (
|
|
||||||
'MultipleTabService' in sourceWindow &&
|
|
||||||
sourceWindow.MultipleTabService.isSelected(aDraggedTab) &&
|
|
||||||
MultipleTabService.allowMoveMultipleTabs
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isSelectionMove) {
|
|
||||||
draggedTabs = sourceWindow.MultipleTabService.getSelectedTabs(sourceBrowser);
|
|
||||||
if (!(aInfo.action & this.kACTIONS_FOR_DESTINATION)) {
|
|
||||||
draggedRoots = [];
|
|
||||||
draggedTabs.forEach(function(aTab) {
|
|
||||||
var parent = aTab,
|
|
||||||
current;
|
|
||||||
do {
|
|
||||||
current = parent;
|
|
||||||
parent = sourceBrowser.treeStyleTab.getParentTab(parent)
|
|
||||||
if (parent && sourceWindow.MultipleTabService.isSelected(parent)) continue;
|
|
||||||
draggedRoots.push(current);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (parent);
|
|
||||||
}, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (aInfo.action & this.kACTIONS_FOR_DESTINATION) {
|
|
||||||
draggedTabs = draggedTabs.concat(sourceBrowser.treeStyleTab.getDescendantTabs(aDraggedTab));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aInfo.action & this.kACTIONS_FOR_SOURCE) {
|
if (aInfo.action & this.kACTIONS_FOR_SOURCE) {
|
||||||
if (aInfo.action & this.kACTION_PART) {
|
if (aInfo.action & this.kACTION_PART) {
|
||||||
this.partTabsOnDrop(draggedRoots);
|
this.partTabsOnDrop(draggedRoots);
|
||||||
@ -2228,7 +2200,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var tab = aTab;
|
var tab = aTab;
|
||||||
if (aInfo.action & this.kACTIONS_FOR_DESTINATION) {
|
if (aInfo.action & this.kACTIONS_FOR_DESTINATION) {
|
||||||
var parent = sourceBrowser.treeStyleTab.getParentTab(aTab);
|
var parent = sourceBrowser.treeStyleTab.getParentTab(aTab);
|
||||||
if (isSelectionMove)
|
if (tabsInfo.isSelectionMove)
|
||||||
sourceWindow.MultipleTabService.setSelection(aTab, false);
|
sourceWindow.MultipleTabService.setSelection(aTab, false);
|
||||||
if (aInfo.action & this.kACTION_IMPORT &&
|
if (aInfo.action & this.kACTION_IMPORT &&
|
||||||
'swapBrowsersAndCloseOther' in targetBrowser) {
|
'swapBrowsersAndCloseOther' in targetBrowser) {
|
||||||
@ -2246,7 +2218,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
oldTabs.push(aTab);
|
oldTabs.push(aTab);
|
||||||
}
|
}
|
||||||
newTabs.push(tab);
|
newTabs.push(tab);
|
||||||
if (isSelectionMove)
|
if (tabsInfo.isSelectionMove)
|
||||||
MultipleTabService.setSelection(tab, true);
|
MultipleTabService.setSelection(tab, true);
|
||||||
if (!parent || draggedTabs.indexOf(parent) < 0)
|
if (!parent || draggedTabs.indexOf(parent) < 0)
|
||||||
newRoots.push(tab);
|
newRoots.push(tab);
|
||||||
@ -2286,6 +2258,56 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getDraggedTabsInfoFromOneTab : function(aInfo, aTab)
|
||||||
|
{
|
||||||
|
aTab = this.getTabFromChild(aTab);
|
||||||
|
|
||||||
|
var targetBrowser = this.mTabBrowser;
|
||||||
|
var tabs = targetBrowser.mTabContainer.childNodes;
|
||||||
|
|
||||||
|
var draggedTabs = [aTab];
|
||||||
|
var draggedRoots = [aTab];
|
||||||
|
|
||||||
|
var sourceWindow = aTab.ownerDocument.defaultView;
|
||||||
|
var sourceBrowser = this.getTabBrowserFromChild(aTab);
|
||||||
|
|
||||||
|
|
||||||
|
var isSelectionMove = (
|
||||||
|
'MultipleTabService' in sourceWindow &&
|
||||||
|
sourceWindow.MultipleTabService.isSelected(aTab) &&
|
||||||
|
MultipleTabService.allowMoveMultipleTabs
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isSelectionMove) {
|
||||||
|
draggedTabs = sourceWindow.MultipleTabService.getSelectedTabs(sourceBrowser);
|
||||||
|
if (!(aInfo.action & this.kACTIONS_FOR_DESTINATION)) {
|
||||||
|
draggedRoots = [];
|
||||||
|
draggedTabs.forEach(function(aTab) {
|
||||||
|
var parent = aTab,
|
||||||
|
current;
|
||||||
|
do {
|
||||||
|
current = parent;
|
||||||
|
parent = sourceBrowser.treeStyleTab.getParentTab(parent)
|
||||||
|
if (parent && sourceWindow.MultipleTabService.isSelected(parent)) continue;
|
||||||
|
draggedRoots.push(current);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (parent);
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (aInfo.action & this.kACTIONS_FOR_DESTINATION) {
|
||||||
|
draggedTabs = draggedTabs.concat(sourceBrowser.treeStyleTab.getDescendantTabs(aTab));
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
draggedTab : aTab,
|
||||||
|
draggedTabs : draggedTabs,
|
||||||
|
draggedRoots : draggedRoots,
|
||||||
|
isSelectionMove : isSelectionMove
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
attachTabsOnDrop : function(aTabs, aParent)
|
attachTabsOnDrop : function(aTabs, aParent)
|
||||||
{
|
{
|
||||||
this.mTabBrowser.movingSelectedTabs = true; // Multiple Tab Handler
|
this.mTabBrowser.movingSelectedTabs = true; // Multiple Tab Handler
|
||||||
@ -2323,7 +2345,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
w.close();
|
w.close();
|
||||||
},
|
},
|
||||||
|
|
||||||
clearDropPosition : function()
|
clearDropPosition : function()
|
||||||
{
|
{
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
@ -2650,7 +2672,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* collapse/expand */
|
/* collapse/expand */
|
||||||
|
|
||||||
collapseExpandSubtree : function(aTab, aCollapse)
|
collapseExpandSubtree : function(aTab, aCollapse)
|
||||||
{
|
{
|
||||||
if (!aTab) return;
|
if (!aTab) return;
|
||||||
@ -2769,7 +2791,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/* scroll */
|
/* scroll */
|
||||||
|
|
||||||
scrollTo : function(aEndX, aEndY)
|
scrollTo : function(aEndX, aEndY)
|
||||||
{
|
{
|
||||||
if (this.getTreePref('tabbar.scroll.smooth')) {
|
if (this.getTreePref('tabbar.scroll.smooth')) {
|
||||||
@ -2783,7 +2805,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
smoothScrollTo : function(aEndX, aEndY)
|
smoothScrollTo : function(aEndX, aEndY)
|
||||||
{
|
{
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
@ -3112,7 +3134,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}, 0, this);
|
}, 0, this);
|
||||||
},
|
},
|
||||||
showHideTabbarReason : 0,
|
showHideTabbarReason : 0,
|
||||||
|
|
||||||
showTabbar : function(aReason)
|
showTabbar : function(aReason)
|
||||||
{
|
{
|
||||||
if (!this.autoHideShown)
|
if (!this.autoHideShown)
|
||||||
@ -3437,7 +3459,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
showHideTabbarOnMousemoveTimer : null,
|
showHideTabbarOnMousemoveTimer : null,
|
||||||
|
|
||||||
cancelShowHideTabbarOnMousemove : function()
|
cancelShowHideTabbarOnMousemove : function()
|
||||||
{
|
{
|
||||||
if (this.showHideTabbarOnMousemoveTimer) {
|
if (this.showHideTabbarOnMousemoveTimer) {
|
||||||
@ -3480,7 +3502,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this
|
this
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
cancelHideTabbarForFeedback : function()
|
cancelHideTabbarForFeedback : function()
|
||||||
{
|
{
|
||||||
if (this.delayedHideTabbarForFeedbackTimer) {
|
if (this.delayedHideTabbarForFeedbackTimer) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user