Bug 897960 - walker should support mozbrowser iframes. r=dcamp
authorPaul Rouget <paul@mozilla.com>
Sun, 08 Sep 2013 11:00:00 +0200
changeset 146125 fab07b9d6dee1b52ede6e8049e8c904369512c15
parent 146124 86b5d8778fc4a5dc978351962c1ce8da096a01b3
child 146126 89a059433037889ef254dd7f587546be126ca3c9
push id25242
push useremorley@mozilla.com
push dateMon, 09 Sep 2013 12:13:52 +0000
treeherdermozilla-central@218d4334d29e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdcamp
bugs897960
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 897960 - walker should support mozbrowser iframes. r=dcamp
browser/devtools/shared/helpers.js
new file mode 100644
--- /dev/null
+++ b/browser/devtools/shared/helpers.js
@@ -0,0 +1,72 @@
+/* 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/. */
+
+const {Cu} = require("chrome");
+Cu.import("resource://gre/modules/Services.jsm");
+
+let { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {});
+XPCOMUtils.defineLazyGetter(this, "PlatformKeys", function() {
+  return Services.strings.createBundle(
+    "chrome://global-platform/locale/platformKeys.properties");
+});
+
+/**
+  * Prettifies the modifier keys for an element.
+  *
+  * @param Node aElemKey
+  *        The key element to get the modifiers from.
+  * @param boolean aAllowCloverleaf
+  *        Pass true to use the cloverleaf symbol instead of a descriptive string.
+  * @return string
+  *         A prettified and properly separated modifier keys string.
+  */
+exports.prettyKey = function Helpers_prettyKey(aElemKey, aAllowCloverleaf) {
+  let elemString = "";
+  let elemMod = aElemKey.getAttribute("modifiers");
+
+  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 (!aAllowCloverleaf) {
+        elemString += "Cmd-";
+      } else {
+        elemString += PlatformKeys.GetStringFromName("VK_META") +
+          PlatformKeys.GetStringFromName("MODIFIER_SEPARATOR");
+      }
+    } 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("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");
+  }
+
+  return elemString +
+    (aElemKey.getAttribute("keycode").replace(/^.*VK_/, "") ||
+     aElemKey.getAttribute("key")).toUpperCase();
+}