From dba843372a95110164bdf6c081d435a41b401335 Mon Sep 17 00:00:00 2001 From: Ian Neal Date: Sun, 5 Jan 2020 22:09:13 +0100 Subject: [PATCH] Bug 1600955 - Port |Bug 501426 - make the open tabs in background pref be named mail.tabs.loadInBackground and allow overriding default for context/middle click with the shift key| to SeaMonkey. r=frg --- suite/app/profile/suite-prefs.js | 4 + .../common/help/mailnews_preferences.xhtml | 3 + .../chrome/mailnews/pref/pref-mailnews.dtd | 2 + .../prefs/content/pref-mailnews.xul | 10 +++ suite/mailnews/content/mailWindowOverlay.xul | 4 +- suite/mailnews/content/msgMail3PaneWindow.js | 19 +++- suite/mailnews/content/tabmail.js | 26 +++--- suite/mailnews/content/tabmail.xml | 88 ++++++++++--------- suite/mailnews/content/threadPane.js | 11 ++- 9 files changed, 101 insertions(+), 66 deletions(-) diff --git a/suite/app/profile/suite-prefs.js b/suite/app/profile/suite-prefs.js index 73364b9ae1..902e28028e 100644 --- a/suite/app/profile/suite-prefs.js +++ b/suite/app/profile/suite-prefs.js @@ -359,6 +359,10 @@ pref("network.auth.non-web-content-triggered-resources-http-auth-allow", true); pref("mail.biff.show_new_alert", true); +// If messages or folders are opened using the context menu or a middle click, +// should we open them in the foreground or in the background? +pref("mail.tabs.loadInBackground", true); + pref("mailnews.ui.deleteMarksRead", true); pref("mailnews.ui.deleteAlwaysSelectedMessages", false); diff --git a/suite/locales/en-US/chrome/common/help/mailnews_preferences.xhtml b/suite/locales/en-US/chrome/common/help/mailnews_preferences.xhtml index 0f317cbec7..e7c87243ce 100644 --- a/suite/locales/en-US/chrome/common/help/mailnews_preferences.xhtml +++ b/suite/locales/en-US/chrome/common/help/mailnews_preferences.xhtml @@ -75,6 +75,9 @@ sorting messages. If it is not selected, &brandShortName; automatically displays the messages unthreaded when you sort them by clicking on the column headers. +
  • Switch to new tabs when opened: Select this to make + &brandShortName; switch to the new tab when opened using Open in New + Tab or Open Message in New Tab context menu options.
  • Only check for new mail after opening Mail & Newsgroups: By default, &brandShortName; checks for new messages even if only a browser window is open. Choose this option if you want to diff --git a/suite/locales/en-US/chrome/mailnews/pref/pref-mailnews.dtd b/suite/locales/en-US/chrome/mailnews/pref/pref-mailnews.dtd index 94a506d4fb..365162dda7 100644 --- a/suite/locales/en-US/chrome/mailnews/pref/pref-mailnews.dtd +++ b/suite/locales/en-US/chrome/mailnews/pref/pref-mailnews.dtd @@ -8,6 +8,8 @@ + + diff --git a/suite/mailnews/components/prefs/content/pref-mailnews.xul b/suite/mailnews/components/prefs/content/pref-mailnews.xul index 56c4f80dee..5420db6f2f 100644 --- a/suite/mailnews/components/prefs/content/pref-mailnews.xul +++ b/suite/mailnews/components/prefs/content/pref-mailnews.xul @@ -27,6 +27,9 @@ + @@ -76,6 +79,13 @@ preference="mailnews.thread_pane_column_unthreads"/> + + + + + oncommand="FolderPaneContextMenuNewTab(event);"/> + oncommand="OpenMessageInNewTab(event);"/> = 0) diff --git a/suite/mailnews/content/tabmail.js b/suite/mailnews/content/tabmail.js index 3b721eb711..4032dfdada 100644 --- a/suite/mailnews/content/tabmail.js +++ b/suite/mailnews/content/tabmail.js @@ -37,11 +37,12 @@ var gMailNewsTabsType = type: "3pane", // aTabInfo belongs to the newly created tab, - // aModeBits is a combination of kTabShow* layout bits (or null), - // aFolderURI designates the folder to select (or null) - // aMsgHdr designates the message to select (or null) - openTab: function(aTabInfo, aModeBits, aFolderURI, aMsgHdr) - { + // aArgs can contain: + // * modeBits is a combination of kTabShow* layout bits (or null), + // * folderURI designates the folder to select (or null) + // * msgHdr designates the message to select (or null) + openTab: function(aTabInfo, {modeBits: aModeBits, folderURI: aFolderURI, + msgHdr: aMsgHdr}) { // clone the current 3pane state before overriding parts of it this.saveTabState(aTabInfo); @@ -525,24 +526,21 @@ function GetTabMail() return document.getElementById("tabmail"); } -function MsgOpenNewTab(aType, aModeBits) -{ +function MsgOpenNewTab(aType, aModeBits, aBackground) { // duplicate the current tab var tabmail = GetTabMail(); if (tabmail) - tabmail.openTab(aType, aModeBits); + tabmail.openTab(aType, {modeBits: aModeBits, background: aBackground}); } -function MsgOpenNewTabForFolder() -{ +function MsgOpenNewTabForFolder(aBackground) { // open current folder in full 3pane tab - MsgOpenNewTab("3pane", kTabModeFolder); + MsgOpenNewTab("3pane", kTabModeFolder, aBackground); } -function MsgOpenNewTabForMessage() -{ +function MsgOpenNewTabForMessage(aBackground) { // open current message in message tab - MsgOpenNewTab("3pane", kTabModeMessage); + MsgOpenNewTab("3pane", kTabModeMessage, aBackground); } // A Thunderbird compatibility function called from e.g. newsblog. diff --git a/suite/mailnews/content/tabmail.xml b/suite/mailnews/content/tabmail.xml index 0a4816c0aa..8e682a7b39 100644 --- a/suite/mailnews/content/tabmail.xml +++ b/suite/mailnews/content/tabmail.xml @@ -37,9 +37,12 @@ - 3) Code that wants to monitor to know when the active tab changes. - - Consumer code should use the following methods: - - * openTab(aTabModeName, arguments...): Open a tab of the given "mode", - - passing the provided arguments. The tab type author should tell you - - the modes they implement and the required/optional arguments. + - * openTab(aTabModeName, aArgs): Open a tab of the given "mode", + - passing the provided arguments as an object. The tab type author + - should tell you the modes they implement and the required/optional + - arguments. + - One of the arguments you can pass is "background": if this is true, + - the tab will be loaded in the background. - * setTabTitle([aOptionalTabInfo]): Tells us that the title of the current - tab (if no argument is provided) or provided tab needs to be updated. - This will result in a call to the tab mode's logic to update the title. @@ -93,22 +96,23 @@ - If this limit is reached, any additional calls to openTab for this - mode will simply result in the first existing tab of this mode being - displayed. - - * shouldSwitchTo(arguments...): Optional function. Called when - - openTab is called on the top-level tabmail binding. It is used to - - decide if the openTab function should switch to an existing tab or - - actually open a new tab. + - * shouldSwitchTo(aArgs): Optional function. Called when openTab is called + - on the top-level tabmail binding. It is used to decide if the openTab + - function should switch to an existing tab or actually open a new tab. - If the openTab function should switch to an existing tab, return the - index of that tab; otherwise return -1. - - * openTab(aTabInfo, arguments...): Called when a tab of the given mode is - - in the process of being opened. aTabInfo will have its "mode" - - attribute set to the mode definition of the tab mode being opened. - - You should set the "title" attribute on it, and may set any other - - attributes you wish for your own use in subsequent functions. Note - - that 'this' points to the tab type definition, not the mode definition - - as you might expect. This allows you to place common logic code on - - the tab type for use by multiple modes and to defer to it. Any - - arguments provided to the caller of tabmail.openTab will be passed to - - your function as well. + - aArgs is a set of named parameters (the ones that are later passed to + - openTab). + - * openTab(aTabInfo, aArgs): Called when a tab of the given mode is in the + - process of being opened. aTabInfo will have its "mode" attribute + - set to the mode definition of the tab mode being opened. You should + - set the "title" attribute on it, and may set any other attributes + - you wish for your own use in subsequent functions. Note that 'this' + - points to the tab type definition, not the mode definition as you + - might expect. This allows you to place common logic code on the + - tab type for use by multiple modes and to defer to it. Any arguments + - provided to the caller of tabmail.openTab will be passed to your + - function as well, including background. - * canCloseTab(aTabInfo): Optional function. - Return true (false) if the tab is (not) allowed to close. - A tab's default permission is stored in aTabInfo.canClose. @@ -362,7 +366,7 @@ - + = 0) { - this.selectTabByIndex(tabIndex); + if (!background) + this.selectTabByIndex(tabIndex); return; } } - // we need to save the state before it gets corrupted - this.saveCurrentTabState(); + if (!background) + // we need to save the state before it gets corrupted + this.saveCurrentTabState(); let tabInfo = {mode: tabMode, canClose: true}; tabMode.tabs.push(tabInfo); @@ -422,19 +431,18 @@ let oldPanel = this.panelContainer.selectedPanel; // Open new tabs in the background? - let switchToNewTab = !this.mPrefs.getBoolPref("browser.tabs.loadInBackground"); - tabInfo.switchToNewTab = switchToNewTab; + tabInfo.switchToNewTab = !background; // the order of the following statements is important let oldTabInfo = this.currentTabInfo; this.tabInfo[this.tabContainer.childNodes.length - 1] = tabInfo; - if (switchToNewTab) - { + if (!background) { this.currentTabInfo = tabInfo; // this has a side effect of calling updateCurrentTab, but our // setting currentTabInfo above will cause it to take no action. - this.tabContainer.selectedIndex = this.tabContainer.childNodes.length - 1; + this.tabContainer.selectedIndex = + this.tabContainer.childNodes.length - 1; } // make sure we are on the right panel let selectedPanel; @@ -458,7 +466,7 @@ { selectedPanel = tabInfo.mode.tabType.panel; } - if (switchToNewTab) + if (!background) this.panelContainer.selectedPanel = selectedPanel; oldPanel.removeAttribute("selected"); @@ -466,27 +474,23 @@ let tabOpenFunc = tabInfo.mode.openTab || tabInfo.mode.tabType.openTab; - let args = [tabInfo].concat(Array.prototype.slice.call(arguments, 1)); if (tabOpenFunc) - tabOpenFunc.apply(tabInfo.mode.tabType, args); + tabOpenFunc.apply(tabInfo.mode.tabType, [tabInfo, aArgs]); - if (!switchToNewTab) - { + if (background) { // if the new tab isn't made current, // its title won't change automatically this.setTabTitle(tabInfo); } - if (this.tabMonitors.length) - { - if (switchToNewTab) - for (let tabMonitor of this.tabMonitors) - tabMonitor.onTabSwitched(tabInfo, oldTabInfo); + if (!background && this.tabMonitors.length) { + for (let tabMonitor of this.tabMonitors) + tabMonitor.onTabSwitched(tabInfo, oldTabInfo); } t.setAttribute("label", tabInfo.title); - if (switchToNewTab) - { + + if (!background) { let docTitle = tabInfo.title; if (AppConstants.platform != "macosx") { docTitle += " - " + gBrandBundle.getString("brandFullName"); @@ -1478,7 +1482,7 @@ { // new-tab-button only appears in the tabstrip // duplicate the current tab - tabmail.openTab(); + tabmail.openTab("", {}); } } ]]> diff --git a/suite/mailnews/content/threadPane.js b/suite/mailnews/content/threadPane.js index 85cd7bc6b4..d59266aae0 100644 --- a/suite/mailnews/content/threadPane.js +++ b/suite/mailnews/content/threadPane.js @@ -19,7 +19,7 @@ function ThreadPaneOnClick(event) // we don't allow new tabs in the search dialog if (document.documentElement.id != "searchMailWindow") { - MsgOpenNewTabForMessage(); + OpenMessageInNewTab(event); RestoreSelectionWithoutContentLoad(GetThreadTree()); } return; @@ -51,7 +51,7 @@ function ThreadPaneOnClick(event) // twisty, don't open the message in a new window. if (event.detail == 2 && !cell.col.cycler && (cell.childElt != "twisty")) { - ThreadPaneDoubleClick(); + ThreadPaneDoubleClick(event); // Double clicking should not toggle the open/close state of the thread. // This will happen if we don't prevent the event from bubbling to the // default handler in tree.xml. @@ -178,8 +178,7 @@ function HandleColumnClick(columnID) } } -function ThreadPaneDoubleClick() -{ +function ThreadPaneDoubleClick(event) { const nsMsgFolderFlags = Ci.nsMsgFolderFlags; if (IsSpecialFolderSelected(nsMsgFolderFlags.Drafts, true)) { @@ -194,7 +193,7 @@ function ThreadPaneDoubleClick() document.documentElement.id != "searchMailWindow") { // we don't allow new tabs in the search dialog // open the message in a new tab on double click - MsgOpenNewTabForMessage(); + OpenMessageInNewTab(event); RestoreSelectionWithoutContentLoad(GetThreadTree()); } else @@ -206,7 +205,7 @@ function ThreadPaneDoubleClick() function ThreadPaneKeyPress(event) { if (event.keyCode == KeyEvent.DOM_VK_RETURN) - ThreadPaneDoubleClick(); + ThreadPaneDoubleClick(event); } function MsgSortByThread()