Bug 897960 - walker should support mozbrowser iframes. Patch B. r=dcamp
authorPaul Rouget <paul@mozilla.com>
Sun, 08 Sep 2013 11:00:00 +0200
changeset 146203 d16b6b1b953e539536a7b259b412500db0d2f807
parent 146202 a160246e2f61a8df9d629530ed5442e8b37a2c45
child 146204 96342fad4321e90f63b7636eaaa79e4a2889f40e
push id25245
push userryanvm@gmail.com
push dateMon, 09 Sep 2013 20:57:55 +0000
treeherdermozilla-central@a468b2e34b04 [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. Patch B. 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();
+}