Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/keySelector.js

Issue 29361133: Issue 4544 - Consider platformHTMLBindings.xml when detecting available keyboard shortcuts (Closed) Base URL: https://hg.adblockplus.org/buildtools
Patch Set: Created Oct. 31, 2016, 10:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | packagerGecko.py » ('j') | templates/bootstrap.js.tmpl » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/keySelector.js
===================================================================
--- a/lib/keySelector.js
+++ b/lib/keySelector.js
@@ -7,16 +7,29 @@ Cu.import("resource://gre/modules/Servic
let validModifiers = Object.create(null);
validModifiers.ACCEL = null;
validModifiers.CTRL = "control";
validModifiers.CONTROL = "control";
validModifiers.SHIFT = "shift";
validModifiers.ALT = "alt";
validModifiers.META = "meta";
+let bindingsKeys = null;
+(function()
+{
+ let request = new XMLHttpRequest();
+ request.open("GET", "chrome://global/content/platformHTMLBindings.xml");
+ request.addEventListener("load", () =>
+ {
+ bindingsKeys = request.responseXML.getElementsByTagName("handler");
+ });
+ request.send();
+})();
+
+
/**
* Sets the correct value of validModifiers.ACCEL.
*/
function initAccelKey()
{
validModifiers.ACCEL = "control";
try
{
@@ -60,17 +73,19 @@ KeySelector.prototype =
*/
_initExistingShortcuts: function(/**ChromeWindow*/ window)
{
if (!validModifiers.ACCEL)
initAccelKey();
this._existingShortcuts = Object.create(null);
- let keys = window.document.getElementsByTagName("key");
+ let keys = Array.prototype.slice.apply(window.document.getElementsByTagName("key"));
+ if (bindingsKeys)
+ keys.push.apply(keys, bindingsKeys);
for (let i = 0; i < keys.length; i++)
{
let key = keys[i];
let keyData =
{
shift: false,
meta: false,
alt: false,
« no previous file with comments | « no previous file | packagerGecko.py » ('j') | templates/bootstrap.js.tmpl » ('J')

Powered by Google App Engine
This is Rietveld