зеркало из https://github.com/mozilla/pjs.git
Allow links in mailnews message pane to open in browser tabs (bug 148974). r=sspitzer; sr=jaggernaut
This commit is contained in:
Родитель
fec9425478
Коммит
d723770d5c
|
@ -645,7 +645,11 @@ Rights Reserved.
|
|||
<menuitem id="context-openlink"
|
||||
label="&openLinkCmd.label;"
|
||||
accesskey="&openLinkCmd.accesskey;"
|
||||
oncommand="gContextMenu.openLink();"/>
|
||||
oncommand="gContextMenu.openLink();"/>
|
||||
<menuitem id="context-openlinkintab"
|
||||
label="&openLinkCmdInTab.label;"
|
||||
accesskey="&openLinkCmdInTab.accesskey;"
|
||||
oncommand="gContextMenu.openLinkInTab();"/>
|
||||
<menuseparator id="messagePaneContext-sep-link"/>
|
||||
<menuitem id="context-selectall"
|
||||
label="&selectAllCmd.label;"
|
||||
|
|
|
@ -181,8 +181,7 @@
|
|||
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") {
|
||||
if (pref && pref.getBoolPref("browser.tabs.opentabfor.middleclick")) {
|
||||
openNewTabWith(href, sendReferrer, event.shiftKey);
|
||||
event.preventBubble();
|
||||
return true;
|
||||
|
|
|
@ -105,9 +105,40 @@ function openNewWindowWith(url, sendReferrer)
|
|||
function openNewTabWith(url, sendReferrer, reverseBackgroundPref)
|
||||
{
|
||||
urlSecurityCheck(url, document);
|
||||
var browser = getBrowser();
|
||||
|
||||
var referrer = sendReferrer ? getReferrer(document) : null;
|
||||
|
||||
var browser;
|
||||
try {
|
||||
// if we're running in a browser window, this should work
|
||||
//
|
||||
browser = getBrowser();
|
||||
|
||||
} catch (ex if ex instanceof ReferenceError) {
|
||||
|
||||
// must be running somewhere else (eg mailnews message pane); need to
|
||||
// find a browser window first
|
||||
//
|
||||
var windowMediator =
|
||||
Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
|
||||
var browserWin = windowMediator.getMostRecentWindow("navigator:browser");
|
||||
|
||||
// if there's no existing browser window, open this url in one, and
|
||||
// return
|
||||
//
|
||||
if (!browserWin) {
|
||||
window.openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no",
|
||||
url, null, referrer);
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise, get the existing browser object
|
||||
//
|
||||
browser = browserWin.getBrowser();
|
||||
}
|
||||
|
||||
var tab = browser.addTab(url, referrer); // open link in new tab
|
||||
if (pref) {
|
||||
var loadInBackground = pref.getBoolPref("browser.tabs.loadInBackground");
|
||||
|
|
Загрузка…
Ссылка в новой задаче