Add new secret option "extensions.treestyletab.autoAttach.fromCurrent" to control new tab position from the current tab (#452)

This commit is contained in:
Piro / YUKI Hiroshi 2013-03-06 02:37:21 +09:00
parent 6fe9401c39
commit 5954e76c02
3 changed files with 18 additions and 8 deletions

View File

@ -155,14 +155,14 @@ var TreeStyleTabWindowHelper = {
nsContextMenu.prototype.openLinkInTab.toSource().replace(
'{',
'{\n' +
' TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);'
' TreeStyleTabService.handleNewTabFromCurrent(this.target.ownerDocument.defaultView);'
)
);
eval('nsContextMenu.prototype.openFrameInTab = '+
nsContextMenu.prototype.openFrameInTab.toSource().replace(
'{',
'{\n' +
' TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);'
' TreeStyleTabService.handleNewTabFromCurrent(this.target.ownerDocument.defaultView);'
)
);
var viewImageMethod = ('viewImage' in nsContextMenu.prototype) ? 'viewImage' : 'viewMedia' ;

View File

@ -518,6 +518,11 @@ pref("extensions.treestyletab.autoAttach.duplicateTabCommand.forward", 1);
* Options are same to extensions.treestyletab.autoAttach.newTabCommand.
*/
pref("extensions.treestyletab.autoAttach.goButton", 1);
/**
* How to treat new tabs from the current tab (links, frames, media, etc.).
* Options are same to extensions.treestyletab.autoAttach.newTabCommand.
*/
pref("extensions.treestyletab.autoAttach.fromCurrent", 1);
/**
* Focus targets for Ctrl-Tab/Ctrl-Shift-Tab.

View File

@ -1100,6 +1100,11 @@ TreeStyleTabWindow.prototype = {
}
},
handleNewTabFromCurrent : function TSTWindow_handleNewTabFromCurrent(aBaseTab)
{
this._handleNewTabCommand(aBaseTab, utils.getTreePref('autoAttach.fromCurrent'));
},
onBeforeNewTabCommand : function TSTWindow_onBeforeNewTabCommand(aTabBrowser)
{
var self = this.windowService || this;
@ -1147,39 +1152,39 @@ TreeStyleTabWindow.prototype = {
onBeforeOpenLink : function TSTWindow_onBeforeOpenLink(aWhere, aOwner)
{
if (aWhere == 'tab' || aWhere == 'tabshifted')
this.readyToOpenChildTab(aOwner);
this.handleNewTabFromCurrent(aOwner);
},
onBeforeOpenLinkWithParams : function TSTWindow_onBeforeOpenLinkWithParams(aParams)
{
if (aParams.linkNode &&
!this.checkToOpenChildTab(aParams.linkNode.ownerDocument.defaultView))
this.readyToOpenChildTab(aParams.linkNode.ownerDocument.defaultView);
this.handleNewTabFromCurrent(aParams.linkNode.ownerDocument.defaultView);
},
onBeforeOpenNewTabByThirdParty : function TSTWindow_onBeforeOpenNewTabByThirdParty(aOwner)
{
if (!this.checkToOpenChildTab(aOwner))
this.readyToOpenChildTab(aOwner);
this.handleNewTabFromCurrent(aOwner);
},
onBeforeBrowserAccessOpenURI : function TSTWindow_onBeforeBrowserAccessOpenURI(aOpener, aWhere)
{
if (aOpener && aWhere == Ci.nsIBrowserDOMWindow.OPEN_NEWTAB)
this.readyToOpenChildTab(aOpener);
this.handleNewTabFromCurrent(aOpener);
},
onBeforeViewMedia : function TSTWindow_onBeforeViewMedia(aEvent, aOwner)
{
if (String(this.window.whereToOpenLink(aEvent, false, true)).indexOf('tab') == 0)
this.readyToOpenChildTab(aOwner);
this.handleNewTabFromCurrent(aOwner);
},
onBeforeBrowserSearch : function TSTWindow_onBeforeBrowserSearch(aTerm, aForceNewTab)
{
if ((arguments.length == 1 || aForceNewTab) &&
this.shouldOpenSearchResultAsChild(aTerm))
this.readyToOpenChildTab();
this.handleNewTabFromCurrent();
},
/* Tree Style Tabの初期化が行われる前に復元されたセッションについてツリー構造を復元 */