Bug 539594 - Middle-clicking back/forward/reload should open the new tab next to the current one. r=mconnor

This commit is contained in:
Dão Gottwald 2010-01-15 09:19:41 +01:00
Родитель 1d1e0469c8
Коммит 72f78edde2
2 изменённых файлов: 34 добавлений и 16 удалений

Просмотреть файл

@ -1611,7 +1611,7 @@ function gotoHistoryIndex(aEvent)
var sessionHistory = getWebNavigation().sessionHistory;
var entry = sessionHistory.getEntryAtIndex(index, false);
var url = entry.URI.spec;
openUILinkIn(url, where);
openUILinkIn(url, where, {relatedToCurrent: true});
return true;
}
}
@ -1631,7 +1631,7 @@ function BrowserForward(aEvent) {
var currentIndex = sessionHistory.index;
var entry = sessionHistory.getEntryAtIndex(currentIndex + 1, false);
var url = entry.URI.spec;
openUILinkIn(url, where);
openUILinkIn(url, where, {relatedToCurrent: true});
}
}
@ -1650,7 +1650,7 @@ function BrowserBack(aEvent) {
var currentIndex = sessionHistory.index;
var entry = sessionHistory.getEntryAtIndex(currentIndex - 1, false);
var url = entry.URI.spec;
openUILinkIn(url, where);
openUILinkIn(url, where, {relatedToCurrent: true});
}
}
@ -1704,7 +1704,8 @@ function BrowserReloadOrDuplicate(aEvent) {
if (where == "current")
BrowserReload();
else
openUILinkIn(getWebNavigation().currentURI.spec, where);
openUILinkIn(getWebNavigation().currentURI.spec, where,
{relatedToCurrent: true});
}
function BrowserReload() {

Просмотреть файл

@ -172,17 +172,33 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
* "window" new window
* "save" save to disk (with no filename hint!)
*
* allowThirdPartyFixup controls whether third party services such as Google's
* aAllowThirdPartyFixup controls whether third party services such as Google's
* I Feel Lucky are allowed to interpret this URL. This parameter may be
* undefined, which is treated as false.
*
* Instead of aAllowThirdPartyFixup, you may also pass an object with any of
* these properties:
* allowThirdPartyFixup (boolean)
* postData (nsIInputStream)
* referrerURI (nsIURI)
* relatedToCurrent (boolean)
*/
function openUILinkIn( url, where, allowThirdPartyFixup, postData, referrerUrl )
{
function openUILinkIn(url, where, aAllowThirdPartyFixup, aPostData, aReferrerURI) {
if (!where || !url)
return;
var aRelatedToCurrent;
if (arguments.length == 3 &&
typeof arguments[2] == "object") {
let params = arguments[2];
aAllowThirdPartyFixup = params.allowThirdPartyFixup;
aPostData = params.postData;
aReferrerURI = params.referrerURI;
aRelatedToCurrent = params.relatedToCurrent;
}
if (where == "save") {
saveURL(url, null, null, true, null, referrerUrl);
saveURL(url, null, null, true, null, aReferrerURI);
return;
}
const Cc = Components.classes;
@ -200,12 +216,12 @@ function openUILinkIn( url, where, allowThirdPartyFixup, postData, referrerUrl )
var allowThirdPartyFixupSupports = Cc["@mozilla.org/supports-PRBool;1"].
createInstance(Ci.nsISupportsPRBool);
allowThirdPartyFixupSupports.data = allowThirdPartyFixup;
allowThirdPartyFixupSupports.data = aAllowThirdPartyFixup;
sa.AppendElement(wuri);
sa.AppendElement(null);
sa.AppendElement(referrerUrl);
sa.AppendElement(postData);
sa.AppendElement(aReferrerURI);
sa.AppendElement(aPostData);
sa.AppendElement(allowThirdPartyFixupSupports);
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
@ -224,18 +240,19 @@ function openUILinkIn( url, where, allowThirdPartyFixup, postData, referrerUrl )
switch (where) {
case "current":
w.loadURI(url, referrerUrl, postData, allowThirdPartyFixup);
w.loadURI(url, aReferrerURI, aPostData, aAllowThirdPartyFixup);
break;
case "tabshifted":
loadInBackground = !loadInBackground;
// fall through
case "tab":
let browser = w.getBrowser();
let browser = w.gBrowser;
browser.loadOneTab(url, {
referrerURI: referrerUrl,
postData: postData,
referrerURI: aReferrerURI,
postData: aPostData,
inBackground: loadInBackground,
allowThirdPartyFixup: allowThirdPartyFixup});
allowThirdPartyFixup: aAllowThirdPartyFixup,
relatedToCurrent: aRelatedToCurrent});
break;
}