Bug 586234 – When middle clicking links in popups, open the new tab in a full browser window

( https://bugzilla.mozilla.org/show_bug.cgi?id=586234 ) の影響で、リンクをタブで開いた時に子タブにならなくなっていたのを修正


git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@7297 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-10-25 02:36:47 +00:00
parent 7d336bfc03
commit f14b0b0d8f
2 changed files with 59 additions and 3 deletions

View File

@ -257,6 +257,7 @@ var TreeStyleTabService = {
if (this.getTreePref('openGroupBookmarkAsTabSubTree') !== null) { if (this.getTreePref('openGroupBookmarkAsTabSubTree') !== null) {
let behavior = 0; let behavior = 0;
if (this.getTreePref('openGroupBookmarkAsTabSubTree.underParent')) if (this.getTreePref('openGroupBookmarkAsTabSubTree.underParent'))
behavior += this.kGROUP_BOOKMARK_USE_DUMMY; behavior += this.kGROUP_BOOKMARK_USE_DUMMY;
if (!this.getTreePref('openGroupBookmarkBehavior.confirm')) { if (!this.getTreePref('openGroupBookmarkBehavior.confirm')) {
behavior += ( behavior += (
@ -1036,12 +1037,12 @@ catch(e) {
let source = this._getFunctionSource(aFunc); let source = this._getFunctionSource(aFunc);
if (!source || !/^\(?function handleLinkClick/.test(source)) if (!source || !/^\(?function handleLinkClick/.test(source))
return false; return false;
eval(aFunc+' = '+source.replace( eval(aFunc+' = '+source.replace( // for -Firefox 3.6
/(openNewTabWith\()/g, /(openNewTabWith\()/g,
<![CDATA[ <![CDATA[
if (!TreeStyleTabService.checkToOpenChildTab(event.target.ownerDocument.defaultView)) TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView); if (!TreeStyleTabService.checkToOpenChildTab(event.target.ownerDocument.defaultView)) TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
$1]]> $1]]>
).replace( ).replace( // for -Firefox 3.6
/(event.ctrlKey|event.metaKey)/, /(event.ctrlKey|event.metaKey)/,
<![CDATA[ <![CDATA[
TreeStyleTabService.checkReadyToOpenNewTabFromLink({ TreeStyleTabService.checkReadyToOpenNewTabFromLink({
@ -1055,7 +1056,7 @@ catch(e) {
) : ) :
(TreeStyleTabService.readyToOpenChildTab(), false) (TreeStyleTabService.readyToOpenChildTab(), false)
]]> ]]>
).replace( ).replace( // for -Firefox 3.6
/* /*
反転された動作通常のリンク読み込みを行う */ 反転された動作通常のリンク読み込みを行う */
'return false;case 1:', 'return false;case 1:',
@ -1082,11 +1083,38 @@ catch(e) {
return false; return false;
case 1: case 1:
]]> ]]>
).replace( // for Firefox 4.0-
'where = whereToOpenLink(event);',
<![CDATA[$&
var TSTFilteringResult = TreeStyleTabService.filterWhereToOpenLink(where, { linkNode : linkNode, event : event });
where = TSTFilteringResult.where;
if (TSTFilteringResult.divertedToTab)
TreeStyleTabService.readyToOpenDivertedTab();
]]>.toString()
).replace( // for Firefox 4.0-
/(if \([^\)]*where == "current")/,
'$1 && !TSTFilteringResult.inverted'
).replace( // for Firefox 4.0-
/(fromContent\s*:\s*true\s*,)/,
'$1 event : event, linkNode : linkNode, '
)); ));
source = null; source = null;
return true; return true;
}, this); }, this);
// for Firefox 4.0-
if ('openLinkIn' in window) {
eval('window.openLinkIn = '+
window.openLinkIn.toSource().replace(
'browser.loadOneTab(',
<![CDATA[
if (!TreeStyleTabService.checkToOpenChildTab(params.linkNode.ownerDocument.defaultView))
TreeStyleTabService.readyToOpenChildTab(params.linkNode.ownerDocument.defaultView);
$&]]>.toString()
)
);
}
this._splitFunctionNames(<![CDATA[ this._splitFunctionNames(<![CDATA[
window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"] window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"]
window.__contentAreaClick window.__contentAreaClick
@ -1477,6 +1505,7 @@ catch(e) {
if (!this.keyEventListeningFlags && this.keyEventListening) { if (!this.keyEventListeningFlags && this.keyEventListening) {
window.removeEventListener('keydown', this, true); window.removeEventListener('keydown', this, true);
window.removeEventListener('keyup', this, true); window.removeEventListener('keyup', this, true);
window.removeEventListener('keypress', this, true); window.removeEventListener('keypress', this, true);
this.keyEventListening = false; this.keyEventListening = false;
} }

View File

@ -1430,6 +1430,33 @@ var TreeStyleTabUtils = {
return this.checkReadyToOpenNewTab(options); return this.checkReadyToOpenNewTab(options);
}, },
filterWhereToOpenLink : function TSTUtils_filterwhereToOpenLink(aWhere, aParams)
{
var inverted = false;
var divertedToTab = false;
var link = aParams.linkNode || aParams.event.originalTarget;
var isNewTab = this.isNewTabAction(aParams.event);
if (this.checkReadyToOpenNewTabFromLink({
link : link,
modifier : isNewTab,
invert : this.getTreePref('link.invertDefaultBehavior')
})) {
if (aWhere == 'current' && !isNewTab) {
divertedToTab = true;
aWhere = this.getPref('browser.tabs.loadInBackground') ? 'tabshifted' : 'tab' ;
}
}
else if (aWhere.indexOf('tab') > -1) {
aWhere = 'current';
inverted = true;
}
return {
where : aWhere,
inverted : inverted,
divertedToTab : divertedToTab
};
},
_getDomainFromURI : function TSTUtils__getDomainFromURI(aURI) _getDomainFromURI : function TSTUtils__getDomainFromURI(aURI)
{ {
if (!aURI) return null; if (!aURI) return null;