mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
ctrl-middleclick should not send a referrer. Bug 175092, r=timeless, sr=jag
This commit is contained in:
parent
723a320270
commit
b37b819702
@ -178,24 +178,19 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
function openNewTabOrWindow(event, href)
|
||||
function openNewTabOrWindow(event, href, sendReferrer)
|
||||
{
|
||||
// should we open it in a new tab?
|
||||
if (pref && pref.getBoolPref("browser.tabs.opentabfor.middleclick") &&
|
||||
("getBrowser" in window) && getBrowser().localName == "tabbrowser") {
|
||||
var loadInBackground = pref.getBoolPref("browser.tabs.loadInBackground");
|
||||
if (event.shiftKey)
|
||||
loadInBackground = !loadInBackground;
|
||||
var theTab = getBrowser().addTab(href, getReferrer(document));
|
||||
if (!loadInBackground)
|
||||
getBrowser().selectedTab = theTab;
|
||||
openNewTabWith(href, sendReferrer, event.shiftKey);
|
||||
event.preventBubble();
|
||||
return true;
|
||||
}
|
||||
|
||||
// should we open it in a new window?
|
||||
if (pref && pref.getBoolPref("middlemouse.openNewWindow")) {
|
||||
openNewWindowWith(href);
|
||||
openNewWindowWith(href, sendReferrer);
|
||||
event.preventBubble();
|
||||
return true;
|
||||
}
|
||||
@ -212,7 +207,7 @@
|
||||
switch (event.button) {
|
||||
case 0: // if left button clicked
|
||||
if (event.metaKey || event.ctrlKey) { // and meta or ctrl are down
|
||||
if (openNewTabOrWindow(event, href))
|
||||
if (openNewTabOrWindow(event, href, true))
|
||||
return true;
|
||||
}
|
||||
var saveModifier = true;
|
||||
@ -233,7 +228,7 @@
|
||||
return true; // do nothing
|
||||
return false;
|
||||
case 1: // if middle button clicked
|
||||
if (openNewTabOrWindow(event, href))
|
||||
if (openNewTabOrWindow(event, href, true))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
@ -249,11 +244,14 @@
|
||||
if (!url)
|
||||
return false;
|
||||
|
||||
// On ctrl-middleclick, open in new window or tab.
|
||||
// On ctrl-middleclick, open in new window or tab. Do not send referrer.
|
||||
if (event.ctrlKey)
|
||||
return openNewTabOrWindow(event, url);
|
||||
return openNewTabOrWindow(event, url, false);
|
||||
|
||||
// If ctrl wasn't down, then just load the url in the current win/tab.
|
||||
if (url != "about:blank") {
|
||||
gURLBar.value = url;
|
||||
}
|
||||
loadURI(url);
|
||||
event.preventBubble();
|
||||
return true;
|
||||
|
@ -86,7 +86,7 @@ function getReferrer(doc)
|
||||
}
|
||||
}
|
||||
|
||||
function openNewWindowWith(url)
|
||||
function openNewWindowWith(url, sendReferrer)
|
||||
{
|
||||
urlSecurityCheck(url, document);
|
||||
|
||||
@ -98,20 +98,25 @@ function openNewWindowWith(url)
|
||||
if (wintype == "navigator:browser")
|
||||
charsetArg = "charset=" + window._content.document.characterSet;
|
||||
|
||||
var referrer = getReferrer(document);
|
||||
var referrer = sendReferrer ? getReferrer(document) : null;
|
||||
window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no", url, charsetArg, referrer);
|
||||
}
|
||||
|
||||
function openNewTabWith(url)
|
||||
function openNewTabWith(url, sendReferrer, reverseBackgroundPref)
|
||||
{
|
||||
urlSecurityCheck(url, document);
|
||||
var browser = getBrowser();
|
||||
|
||||
var referrer = getReferrer(document);
|
||||
var referrer = sendReferrer ? getReferrer(document) : null;
|
||||
var tab = browser.addTab(url, referrer); // open link in new tab
|
||||
if (pref) {
|
||||
var loadInBackground = pref.getBoolPref("browser.tabs.loadInBackground");
|
||||
if (reverseBackgroundPref)
|
||||
loadInBackground = !loadInBackground;
|
||||
|
||||
if (pref && !pref.getBoolPref("browser.tabs.loadInBackground"))
|
||||
browser.selectedTab = tab;
|
||||
if (!loadInBackground)
|
||||
browser.selectedTab = tab;
|
||||
}
|
||||
}
|
||||
|
||||
function findParentNode(node, parentNode)
|
||||
|
@ -524,12 +524,12 @@ nsContextMenu.prototype = {
|
||||
// Open linked-to URL in a new window.
|
||||
openLink : function () {
|
||||
// Determine linked-to URL.
|
||||
openNewWindowWith( this.linkURL() );
|
||||
openNewWindowWith( this.linkURL(), true );
|
||||
},
|
||||
// Open linked-to URL in a new tab.
|
||||
openLinkInTab : function () {
|
||||
// Determine linked-to URL.
|
||||
openNewTabWith( this.linkURL() );
|
||||
openNewTabWith( this.linkURL(), true, false );
|
||||
},
|
||||
// Open frame in a new tab.
|
||||
openFrameInTab : function () {
|
||||
|
Loading…
Reference in New Issue
Block a user