コンテキストメニューや戻るボタンなどから開くタブもツリーに組み込むようにした

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1255 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-10-20 19:24:34 +00:00
parent 0127a9c698
commit aa80bfbf3f

View File

@ -249,20 +249,71 @@ var TreeStyleTabService = {
this.addPrefListener(this);
this.observe(null, 'nsPref:changed', 'extensions.treestyletab.levelMargin');
eval('nsContextMenu.prototype.openLinkInTab = '+
nsContextMenu.prototype.openLinkInTab.toSource().replace(
'{',
<><![CDATA[
{
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
]]></>
)
);
eval('nsContextMenu.prototype.openFrameInTab = '+
nsContextMenu.prototype.openFrameInTab.toSource().replace(
'{',
<><![CDATA[
{
TreeStyleTabService.readyToOpenChildTab(this.target.ownerDocument.defaultView);
]]></>
)
);
eval('window.handleLinkClick = '+
window.handleLinkClick.toSource().replace(
/openNewTabWith/g,
<><![CDATA[
TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
openNewTabWith(]]></>
)
);
eval('window.gotoHistoryIndex = '+
window.gotoHistoryIndex.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.BrowserForward = '+
window.BrowserForward.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.BrowserBack = '+
window.BrowserBack.toSource().replace(
/openUILinkIn/g,
<><![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
openUILinkIn]]></>
)
);
eval('window.nsBrowserAccess.prototype.openURI = '+
window.nsBrowserAccess.prototype.openURI.toSource().replace(
/switch\s*\(aWhere\)/,
<><![CDATA[
if (aOpener &&
aWhere == Components.interfaces.nsIBrowserDOMWindow.OPEN_NEWTAB) {
(function(aOpener) {
var ownerBrowser = ('SplitBrowser' in window) ? TreeStyleTabService.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(aOpener.top).browser) : gBrowser ;
var parentTab = TreeStyleTabService.getTabFromFrame(aOpener, ownerBrowser);
ownerBrowser.__treestyletab__readyToAttachNewTab = true;
ownerBrowser.__treestyletab__readyToAttachMultiple = false;
ownerBrowser.__treestyletab__parentTab = parentTab.getAttribute(TreeStyleTabService.kID);
})(aOpener);
TreeStyleTabService.readyToOpenChildTab(aOpener);
}
switch(aWhere)
]]></>
@ -1513,6 +1564,17 @@ catch(e) {
}
},
readyToOpenChildTab : function(aFrame)
{
if (!aFrame)
aFrame = TreeStyleTabService.browser.contentWindow;
var ownerBrowser = ('SplitBrowser' in window) ? this.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(aFrame.top).browser) : gBrowser ;
ownerBrowser.__treestyletab__readyToAttachNewTab = true;
ownerBrowser.__treestyletab__readyToAttachMultiple = false;
ownerBrowser.__treestyletab__parentTab = this.getTabFromFrame(aFrame, ownerBrowser).getAttribute(this.kID);
},
/* attach/part */
attachTabTo : function(aChild, aParent, aInfo)