Bug 237027 - Properly handle accel keys in address bar on macOS. r?Gijs
MozReview-Commit-ID: F8gkCf9FXhS
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -396,23 +396,30 @@ file, You can obtain one at http://mozil
selectedOneOff.doCommand();
return;
}
let where = openUILinkWhere;
if (!where) {
if (isMouseEvent) {
where = whereToOpenLink(event, false, false);
+ } else if (!event || isTabEmpty(gBrowser.selectedTab)) {
+ // Always reuse empty tab.
+ where = "current";
} else {
- // If the current tab is empty, ignore Alt+Enter (reuse this tab)
- let altEnter = !isMouseEvent &&
- event &&
- event.altKey &&
- !isTabEmpty(gBrowser.selectedTab);
- where = altEnter ? "tab" : "current";
+ where = "current";
+ if (event.altKey) {
+ where = "tab";
+ } else if (this.AppConstants.platform == "macosx") {
+ if (event.metaKey) {
+ where = event.shiftKey ? "tabshifted" : "tab";
+ } else if (event.shiftKey) {
+ where = "window";
+ }
+ }
}
}
let url = this.value;
if (!url) {
return;
}
@@ -631,24 +638,23 @@ file, You can obtain one at http://mozil
<method name="maybeCanonizeURL">
<parameter name="aTriggeringEvent"/>
<parameter name="aUrl"/>
<body><![CDATA[
// Only add the suffix when the URL bar value isn't already "URL-like",
// and only if we get a keyboard event, to match user expectations.
if (!/^\s*[^.:\/\s]+(?:\/.*|\s*)$/i.test(aUrl) ||
- !(aTriggeringEvent instanceof KeyEvent)) {
+ !(aTriggeringEvent instanceof KeyEvent) ||
+ this.AppConstants.platform == "macosx") {
return;
}
let url = aUrl;
- let accel = this.AppConstants.platform == "macosx" ?
- aTriggeringEvent.metaKey :
- aTriggeringEvent.ctrlKey;
+ let accel = aTriggeringEvent.ctrlKey;
let shift = aTriggeringEvent.shiftKey;
let suffix = "";
switch (true) {
case (accel && shift):
suffix = ".org/";
break;
case (shift):