From b37b819702c0752d5cecf89cb7f427daa12cf93e Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Wed, 6 Nov 2002 01:51:02 +0000 Subject: [PATCH] ctrl-middleclick should not send a referrer. Bug 175092, r=timeless, sr=jag --- .../resources/content/contentAreaClick.js | 22 +++++++++---------- .../resources/content/contentAreaUtils.js | 17 +++++++++----- .../resources/content/nsContextMenu.js | 4 ++-- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/xpfe/communicator/resources/content/contentAreaClick.js b/xpfe/communicator/resources/content/contentAreaClick.js index e21a45469190..71e2dbdea907 100644 --- a/xpfe/communicator/resources/content/contentAreaClick.js +++ b/xpfe/communicator/resources/content/contentAreaClick.js @@ -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; diff --git a/xpfe/communicator/resources/content/contentAreaUtils.js b/xpfe/communicator/resources/content/contentAreaUtils.js index 3115cd2302b5..dd2d231e3ea7 100644 --- a/xpfe/communicator/resources/content/contentAreaUtils.js +++ b/xpfe/communicator/resources/content/contentAreaUtils.js @@ -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) diff --git a/xpfe/communicator/resources/content/nsContextMenu.js b/xpfe/communicator/resources/content/nsContextMenu.js index ee7d4d5788f2..b5724d65d965 100644 --- a/xpfe/communicator/resources/content/nsContextMenu.js +++ b/xpfe/communicator/resources/content/nsContextMenu.js @@ -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 () {