Files
palemoon27/toolkit/modules/ShortcutUtils.jsm
roytam1 6d98d4a091 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1171841 - Add valgrind to the base ubuntu-builders packages; r=dustin (8819d73727)
- bug 1175651 - add uuid-dev+sqlite3 to ubuntu-build container. r=mrrrgn (af79c565b8)
- Bug 1161075: build android with JDK from tooltool; r=nalexander (1791cb41d7)
- Bug 1154827 - Add a base desktop 32 bit builder; r=dustin (9aaf9bb1f4)
- Bug 1154827 - Add a base ubuntu 32 bit builder; r=dustin (d90836295a)
- Bug 1176960 - Fix broken tc-vcs install version; r=dustin (ec85d56bd0)
- Bug 1178161 - Base 32 bit builders on a base image that we control; r=dustin (202bb5cc14)
- Bug 1189949: regenerate all desktop builders to get new tooltool; r=mrrrgn (b5413eae36)
- Bug 1176961 - Image builds should fail if tc-vcs fails to install; r=dustin (7fb42779ce)
- Bug 1188608 - Update ubuntu builders to use tc-vcs 2.3.8 r=mrrrgn (2ca9508679)
- Bug 1185643: use in-tree mozharness for builds; r=wander (6a0020d794)
- Bug 1199379: drop root before beginning the build r=ted.mielczarek (1e1ae3ab7e)
- bug 1182520 - Put Taskcluster task definition for mac-cross builds in tree. r=dustin (05b46d4c99)
- Bug 1189892: build on CentOS 6.<latest>; r=glandium r=mrrrgn (f0c4663543)
- Bug 1188405 - Convert gDevTools/gDevToolsBrowser into modules. r=jryans (d8b1e8d206)
- Bug 1188405 - Ensure initializing main client module when running the Browser Toolbox. r=jryans (e1914ab60e)
- Bug 1246692 - Test that the browser toolbox has a working console. r=jryans (c3edc02138)
- Bug 1165468 - Upgrade to git 2.4 r=garndt (a0d8e2659d)
- Bug 1148630: Add support for upload symbols from docker image. (46b1eb653c)
- Bug 1171026: Fix exit code for phone-builder image. r=garndt a=garndt (8807211317)
- Bug 1177190: Update libcurl in docker images. r=selenamarie (a3a5b07666)
- Bug 1188608 - Update tc-vcs to 2.3.8 in builders r=wcosta (4287e344c0)
- Bug 1148995 - Display error message returned by testdroid endpoint r=me a=taskcluster-only (6fae6db819)
- Bug 1172336 - Provide phone capabilities within payload instead of env variable r=wcosta (6c15198229)
- Bug 1140587 - Reduce pip warnings a=config-only r=me (09acbabab7)
- Bug 1147977 - Add additional timeouts and retries to curl downloads in tc-vcs r=jonasfj (1dfdffba5f)
- Bug 1151877 - Disable pip upgrade checks r=me (f51c76d303)
- Bug 1131156 - Add tc-vcs cache to tests r=garndt (413df76132)
- Bug 1148817 - Use machine local pip caches r=me a=taskcluster-only (b35f475068)
- Bug 1163057 - Allow loopback devices to be used within tasks. r=lightsofapollo (102c322f6b)
- bug 1159960 - Update tester docker image. r=lightsofapollo (549d5515db)
- Bug 1165488 - Update tester docker image. r=jlal (97d0a11244)
- Bug 1188608 - Update tester and tester-device images for tc-vcs 2.3.8 r=wcosta (7435255f9c)
- Bug 1198876 - Update docker images to use taskcluster-vcs 2.3.9 r=wcosta (3d8dc2e1be)
- Bug 1203965 - Update images to use taskcluster-vcs 2.3.12 r=wcosta (baecc0950c)
- Bug 1136026 - Ensure ccache has enough space and is tied to specific caches r=wcosta (47b833c527)
- Bug 1150145 - (reland) Upload fxos simulator r=garndt (983141c92f)
- Bug 1152840 - Add build symbols for mulet/b2g-desktop r=garndt (e690ef9ac2)
- Bug 1240494 - AMD support for DevTools loaders. r=jwalker,Honza (894ee3403a)
- Bug 1226661 - DevTools client JSM global tweak for B2G. r=ochameau (82577730c6)
- Bug 1123443 - Add in-tree test configuration for Android 4.4 emulator unit tests; r=armenzg (8629e5a8eb)
- Bug 1062365 - Rename in-tree config for android 4.3 emulator; r=kmoir (9b3a58d6b7)
- Bug 1083347 - Removing gl.json and editing in-tree configurations.r=armenzg, gbrown DONTBUILD (3d01be7e91)
- Bug 1083347 - Removing android.json, android23.json, androidx86.json. r=jmaher (1ff0b0ce2f)
- bits of  Bug 1143218 (c5da30ab6e)
- Bug 1146574 - Update Android 4.3 configs for cppunit; r=dminor (b2165696f7)
- Revert "bits of 890105 and 893682" Breaks classic theme on Mac. (7d13e72039)
- part of Bug 1177782 - Enable --screenshot-on-fail for mochitests, r=jgriffin (94797e9f0f)
- bits at status Bug 917999 - Part 3 (2f1d716694)
- Bug 1173507: Avoid cache bustage. r=garndt (9881689266)
- some mac style updates (f9e1ec8254)
- Bug 1179687 - Fix TC emulator builds to upload test packages and test_packages.json correctly. r=garndt (49bca8cf5b)
2023-10-16 09:09:50 +08:00

114 lines
3.8 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
this.EXPORTED_SYMBOLS = ["ShortcutUtils"];
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "PlatformKeys", function() {
return Services.strings.createBundle(
"chrome://global-platform/locale/platformKeys.properties");
});
XPCOMUtils.defineLazyGetter(this, "Keys", function() {
return Services.strings.createBundle(
"chrome://global/locale/keys.properties");
});
var ShortcutUtils = {
/**
* Prettifies the modifier keys for an element.
*
* @param Node aElemKey
* The key element to get the modifiers from.
* @param boolean aNoCloverLeaf
* Pass true to use a descriptive string instead of the cloverleaf symbol. (OS X only)
* @return string
* A prettified and properly separated modifier keys string.
*/
prettifyShortcut: function(aElemKey, aNoCloverLeaf) {
let elemString = "";
let elemMod = aElemKey.getAttribute("modifiers");
let haveCloverLeaf = false;
if (elemMod.match("accel")) {
if (Services.appinfo.OS == "Darwin") {
// XXX bug 779642 Use "Cmd-" literal vs. cloverleaf meta-key until
// Orion adds variable height lines.
if (aNoCloverLeaf) {
elemString += "Cmd-";
} else {
haveCloverLeaf = true;
}
} else {
elemString += PlatformKeys.GetStringFromName("VK_CONTROL") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
}
if (elemMod.match("access")) {
if (Services.appinfo.OS == "Darwin") {
elemString += PlatformKeys.GetStringFromName("VK_CONTROL") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
} else {
elemString += PlatformKeys.GetStringFromName("VK_ALT") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
}
if (elemMod.match("os")) {
elemString += PlatformKeys.GetStringFromName("VK_WIN") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("shift")) {
elemString += PlatformKeys.GetStringFromName("VK_SHIFT") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("alt")) {
elemString += PlatformKeys.GetStringFromName("VK_ALT") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("ctrl") || elemMod.match("control")) {
elemString += PlatformKeys.GetStringFromName("VK_CONTROL") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
if (elemMod.match("meta")) {
elemString += PlatformKeys.GetStringFromName("VK_META") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
if (haveCloverLeaf) {
elemString += PlatformKeys.GetStringFromName("VK_META") +
PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
}
let key;
let keyCode = aElemKey.getAttribute("keycode");
if (keyCode) {
try {
// Some keys might not exist in the locale file, which will throw:
key = Keys.GetStringFromName(keyCode.toUpperCase());
} catch (ex) {
Cu.reportError("Error finding " + keyCode + ": " + ex);
key = keyCode.replace(/^VK_/, '');
}
} else {
key = aElemKey.getAttribute("key");
key = key.toUpperCase();
}
return elemString + key;
},
findShortcut: function(aElemCommand) {
let document = aElemCommand.ownerDocument;
return document.querySelector("key[command=\"" + aElemCommand.getAttribute("id") + "\"]");
}
};
Object.freeze(ShortcutUtils);
this.ShortcutUtils = ShortcutUtils;