зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1081542 - Part 7: Reflect middle click to window.open. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D201935
This commit is contained in:
Родитель
ff1e8777a6
Коммит
59527637b8
|
@ -64,6 +64,7 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/StaticPrefs_browser.h"
|
||||
#include "mozilla/StaticPrefs_middlemouse.h"
|
||||
#include "mozilla/StaticPrefs_full_screen_api.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Storage.h"
|
||||
|
@ -2455,7 +2456,12 @@ bool nsWindowWatcher::IsWindowOpenLocationModified(
|
|||
bool metaKey = aModifiers.IsControl();
|
||||
#endif
|
||||
bool shiftKey = aModifiers.IsShift();
|
||||
if (metaKey) {
|
||||
|
||||
bool middleMouse = aModifiers.IsMiddleMouse();
|
||||
bool middleUsesTabs = StaticPrefs::browser_tabs_opentabfor_middleclick();
|
||||
bool middleUsesNewWindow = StaticPrefs::middlemouse_openNewWindow();
|
||||
|
||||
if (metaKey || (middleMouse && middleUsesTabs)) {
|
||||
bool loadInBackground = StaticPrefs::browser_tabs_loadInBackground();
|
||||
if (shiftKey) {
|
||||
loadInBackground = !loadInBackground;
|
||||
|
@ -2467,11 +2473,18 @@ bool nsWindowWatcher::IsWindowOpenLocationModified(
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (shiftKey) {
|
||||
|
||||
if (shiftKey || (middleMouse && !middleUsesTabs && middleUsesNewWindow)) {
|
||||
*aLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
|
||||
return true;
|
||||
}
|
||||
|
||||
// If both middleUsesTabs and middleUsesNewWindow are false, it means the
|
||||
// middle-click is used for different purpose, such as paste or scroll.
|
||||
// Webpage still can trigger `window.open` for the user activation, and in
|
||||
// that case use the `window.open`'s `features` parameter and other prefs to
|
||||
// decide where to open.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ add_task(async function testStopStartingAutoScroll() {
|
|||
"accessibility.mouse_focuses_formcontrol",
|
||||
!navigator.platform.includes("Mac"),
|
||||
],
|
||||
["browser.tabs.loadInBackground", false],
|
||||
],
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче