Scroll to opened tab group even if TMP is not installed

This commit is contained in:
YUKI Hiroshi 2015-03-19 10:47:49 +09:00
parent 65007f64e6
commit 609400e19a

View File

@ -243,7 +243,7 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabService, {
'$1, aFolderTitle$2' '$1, aFolderTitle$2'
).replace( ).replace(
'{', '{',
'{ var TSTTreeStructure = null, TSTPreviousTabs, TSTOpenGroupBookmarkBehavior;' '{ var TSTTreeStructure = null, TSTPreviousTabs, TSTTreeStructureApplied = true, TSTOpenGroupBookmarkBehavior;'
).replace( ).replace(
'var urls = [];', 'var urls = [];',
'$& var ids = [];' '$& var ids = [];'
@ -258,6 +258,7 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabService, {
'var TSTResult = browserWindow.TreeStyleTabBookmarksService.handleTabsOpenProcess(where, aEvent, browserWindow, ids, urls, aFolderTitle);\n' + 'var TSTResult = browserWindow.TreeStyleTabBookmarksService.handleTabsOpenProcess(where, aEvent, browserWindow, ids, urls, aFolderTitle);\n' +
'TSTTreeStructure = TSTResult.treeStructure;\n' + 'TSTTreeStructure = TSTResult.treeStructure;\n' +
'TSTPreviousTabs = TSTResult.previousTabs;\n' + 'TSTPreviousTabs = TSTResult.previousTabs;\n' +
'TSTTreeStructureApplied = TSTResult.treeStructureApplied;\n' +
'TSTOpenGroupBookmarkBehavior = TSTResult.behavior;\n' + 'TSTOpenGroupBookmarkBehavior = TSTResult.behavior;\n' +
'if (typeof replaceCurrentTab != "undefined")\n' + 'if (typeof replaceCurrentTab != "undefined")\n' +
' replaceCurrentTab = TSTResult.replaceCurrentTab;\n' + ' replaceCurrentTab = TSTResult.replaceCurrentTab;\n' +
@ -266,8 +267,9 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabService, {
/(\}\)?)$/, /(\}\)?)$/,
' if (TSTTreeStructure && TSTPreviousTabs) {\n' + ' if (TSTTreeStructure && TSTPreviousTabs) {\n' +
' let tabs = browserWindow.TreeStyleTabService.getNewTabsFromPreviousTabsInfo(browserWindow.gBrowser, TSTPreviousTabs);\n' + ' let tabs = browserWindow.TreeStyleTabService.getNewTabsFromPreviousTabsInfo(browserWindow.gBrowser, TSTPreviousTabs);\n' +
' browserWindow.gBrowser.treeStyleTab.scrollToTabs(tabs);\n' + ' if (!TSTTreeStructureApplied)\n' +
' browserWindow.TreeStyleTabService.applyTreeStructureToTabs(tabs, TSTTreeStructure, TSTOpenGroupBookmarkBehavior & browserWindow.TreeStyleTabBookmarksService.kGROUP_BOOKMARK_EXPAND_ALL_TREE);\n' + ' browserWindow.TreeStyleTabService.applyTreeStructureToTabs(tabs, TSTTreeStructure, TSTOpenGroupBookmarkBehavior & browserWindow.TreeStyleTabBookmarksService.kGROUP_BOOKMARK_EXPAND_ALL_TREE);\n' +
' browserWindow.gBrowser.treeStyleTab.scrollToTabs(tabs);\n' +
' }\n' + ' }\n' +
'$1' '$1'
)); ));
@ -385,7 +387,8 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabService, {
var result = { var result = {
behavior : undefined, behavior : undefined,
treeStructure : undefined, treeStructure : undefined,
previousTabs : undefined previousTabs : undefined,
treeStructureApplied : false
}; };
if ( if (
aEvent.type != 'drop' && aEvent.type != 'drop' &&
@ -445,14 +448,17 @@ var TreeStyleTabBookmarksService = inherit(TreeStyleTabService, {
} }
} }
result.treeStructure = treeStructure;
result.previousTabs = aBrowserWindow.TreeStyleTabService.getTabsInfo(aBrowserWindow.gBrowser);
if (TreeStyleTabUtils.getTreePref('compatibility.TMP') && if (TreeStyleTabUtils.getTreePref('compatibility.TMP') &&
'TMP_Places' in aBrowserWindow && 'TMP_Places' in aBrowserWindow &&
'openGroup' in aBrowserWindow.TMP_Places) { 'openGroup' in aBrowserWindow.TMP_Places) {
result.treeStructure = treeStructure; result.treeStructureApplied = false;
result.previousTabs = aBrowserWindow.TreeStyleTabService.getTabsInfo(aBrowserWindow.gBrowser);
} }
else { else {
sv.readyToOpenNewTabGroup(null, treeStructure, result.behavior & sv.kGROUP_BOOKMARK_EXPAND_ALL_TREE); sv.readyToOpenNewTabGroup(null, treeStructure, result.behavior & sv.kGROUP_BOOKMARK_EXPAND_ALL_TREE);
result.treeStructureApplied = true;
} }
} }
return result; return result;