Skip to content

Commit

Permalink
Merge pull request #199 from gifnksm/fx46
Browse files Browse the repository at this point in the history
Support Firefx 46
  • Loading branch information
mooz committed Mar 23, 2016
2 parents 20c77d4 + 2221cb6 commit 48f6a2a
Show file tree
Hide file tree
Showing 34 changed files with 202 additions and 179 deletions.
4 changes: 2 additions & 2 deletions components/keysnail-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ KeySnailLoader.prototype = {

let context = win.KeySnail.modules;

for (let [, module] in Iterator(modules))
for (let module of modules)
loadModule(module, context);
},

Expand All @@ -122,7 +122,7 @@ KeySnailLoader.prototype = {
"password1Container",
"password2Container"];

for (let [, id] in Iterator(ids))
for (let id of ids)
{
let elem = aDocument.getElementById(id);
if (elem && !elem.hidden)
Expand Down
4 changes: 2 additions & 2 deletions content/keysnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
_ = modules._;
} catch (x) {}

for (let [, name] in Iterator(moduleObjects))
for (let name of moduleObjects)
this.initModule(name);

// set modules
Expand Down Expand Up @@ -593,7 +593,7 @@
if (pluginUpdater.checking)
return;

let paths = [path for ([path, plugin] in Iterator(plugins.context))];
let paths = [for (path of Object.keys(plugins.context)) path];

pluginUpdater.checking = true;
pluginUpdater.pluginsWithUpdate = [];
Expand Down
2 changes: 1 addition & 1 deletion content/modules/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ var command = {
return node && /^(https?|ftp):/.test(node.uri);
}

var urlList = [getInfo(item) for ([, item] in Iterator(items)) if (isBookmarkItem(item))];
var urlList = [for (item of items) if (isBookmarkItem(item)) getInfo(item)];

prompt.selector(
{
Expand Down
2 changes: 1 addition & 1 deletion content/modules/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var ext = function () {
}
keyList = keyList.sort();

for (let [, name] in Iterator(keyList))
for (let name of keyList)
extList.push([name, exts[name].description || ""]);

return extList;
Expand Down
2 changes: 1 addition & 1 deletion content/modules/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ var hook = {
if (!hook)
return;

for (let [i, action] in Iterator(hook)) {
for (let [i, action] of util.keyValues(hook)) {
try {
action(arg);
} catch (x) {
Expand Down
10 changes: 5 additions & 5 deletions content/modules/key.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ var key = {

this.passAllKeys = true;

for (let [, keyStr] in Iterator(aKeys)) {
for (let [, type] in Iterator(aType)) {
for (let keyStr of aKeys) {
for (let type of aType) {
util.message("feed " + keyStr);
let event = this.stringToKeyEvent(keyStr, true, type, true);
// event.ksNoHandle becomes undefined while propagating
Expand Down Expand Up @@ -1049,7 +1049,7 @@ var key = {
var aTarget = this.keyMapHolder[aTargetKeyMapName];
var aDestination = this.keyMapHolder[aDestinationKeyMapName];

for (let [property, value] in Iterator(aTarget))
for (let [property, value] of util.keyValues(aTarget))
aDestination[property] = value;
},

Expand Down Expand Up @@ -1104,7 +1104,7 @@ var key = {
if (!(aKeyMapName instanceof Array))
aKeyMapName = [aKeyMapName];

for (let [, keyMapName] in Iterator(aKeyMapName))
for (let keyMapName of aKeyMapName)
{
var addTo = this.keyMapHolder[keyMapName];

Expand Down Expand Up @@ -1348,7 +1348,7 @@ var key = {
if (!aKeySequence)
aKeySequence = [];

for (let [keyStr, cont] in Iterator(aKeyMap))
for (let [keyStr, cont] of util.keyValues(aKeyMap))
{
switch (typeof cont)
{
Expand Down
2 changes: 1 addition & 1 deletion content/modules/macro.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var macro = {
var len = aEvents.length;
var sleepTime = this.sleepTime;

for (let [, event] in Iterator(aEvents))
for (let event of aEvents)
{
if (event.keyCode === KeyEvent.DOM_VK_TAB)
{
Expand Down
4 changes: 2 additions & 2 deletions content/modules/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var plugins = {
setupOptions: function (prefix, defaults, pluginInfo) {
let options = {};

for (let [name, { preset, description, type, hidden }] in Iterator(defaults)) {
for (let [name, { preset, description, type, hidden }] of util.keyValues(defaults)) {
let fullName = prefix + "." + name;

// XXX: bind values
Expand Down Expand Up @@ -107,7 +107,7 @@ var plugins = {
getInstalledPlugins: function () {
let pluginList = {};

for (let [pluginPath, pluginContext] in Iterator(plugins.context)) {
for (let [pluginPath, pluginContext] of util.keyValues(plugins.context)) {
let isDisabled = userscript.isDisabledPlugin(pluginPath);
let isNotCompatible = pluginContext.__ksNotCompatible__;

Expand Down
56 changes: 27 additions & 29 deletions content/modules/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ var prompt = function () {
function $E(aName, aAttributes) {
let elem = document.createElement(aName);

for (let [k, v] in Iterator(aAttributes))
for (let [k, v] of util.keyValues(aAttributes))
elem.setAttribute(k, v);

return elem;
}

function implant(a, b) {
for (let [k, v] in Iterator(b))
for (let [k, v] of util.keyValues(b))
a[k] = v;
}

function implantAll(a, b) {
for (let k in util.getAllPropertyNames(b)) {
for (let k of util.getAllPropertyNames(b)) {
try {
a[k] = b[k];
} catch (_) {}
Expand All @@ -193,10 +193,10 @@ var prompt = function () {
var newObject = {};
var key;

for (let [key, value] in Iterator(a))
for (let [key, value] of util.keyValues(a))
newObject[key] = value;

for (let [key, value] in Iterator(b))
for (let [key, value] of util.keyValues(b))
newObject[key] = value;

return newObject;
Expand All @@ -210,7 +210,7 @@ var prompt = function () {

function getActualCols(aCols) {
if (gFlags)
for (let [, flag] in Iterator(gFlags))
for (let flag of gFlags)
if (flag & (HIDDEN | ICON)) aCols--;
return aCols;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ var prompt = function () {
function setColumns(aColumn) {
if (gFlags)
{
for (let [, flag] in Iterator(gFlags))
for (let flag of gFlags)
{
if (flag & (HIDDEN | ICON))
aColumn--;
Expand Down Expand Up @@ -726,7 +726,7 @@ var prompt = function () {
var found = {};
var uniqStr = "";

for (let [, c] in Iterator(str))
for (let c of str)
{
if (found[c])
continue;
Expand All @@ -749,7 +749,7 @@ var prompt = function () {

var continuousMode = false;

for (let [, opt] in Iterator(uniq(opts)))
for (let opt of uniq(opts))
{
switch (opt)
{
Expand Down Expand Up @@ -1016,7 +1016,7 @@ var prompt = function () {
if (typeof aActions === "function")
aActions = [[aActions, "Default callback"]];

for (let [i, action] in Iterator(aActions))
for (let [i, action] of util.keyValues(aActions))
{
var item = document.createElement("menuitem");
item.setAttribute("label", action[1]);
Expand Down Expand Up @@ -1047,7 +1047,7 @@ var prompt = function () {
);

function stick(keymap) {
for (let [k, a] in Iterator(keymap))
for (let [k, a] of util.keyValues(keymap))
{
let act = a.split(",")[0];
let desc = actionDescriptionMap[act] || "";
Expand Down Expand Up @@ -1091,7 +1091,7 @@ var prompt = function () {
var list = [];

// create action list and local command
for (let [i, action] in Iterator(aActions))
for (let [i, action] of util.keyValues(aActions))
{
let index = i + 1;
list.push([action[0], index.toString() + ". " + action[1]]);
Expand Down Expand Up @@ -1201,7 +1201,7 @@ var prompt = function () {
}
}).filter(function (r) r);

var cellForSearch = gFlags ? [i for (i in gFlags) if ((gFlags[i] & IGNORE) === 0)] : null;
var cellForSearch = gFlags ? [for (i of Object.keys(gFlags)) if ((gFlags[i] & IGNORE) === 0) i] : null;

// reduce prototype chaine
let list = wholeList;
Expand Down Expand Up @@ -1456,7 +1456,7 @@ var prompt = function () {
let buffer = [];
let escapeIt = false;

for (let [, c] in Iterator(str))
for (let c of str)
{
if (!escapeIt && c === escapeChar)
escapeIt = true;
Expand Down Expand Up @@ -1734,7 +1734,7 @@ var prompt = function () {
collection : null
};

for (let [, cmpltr] in Iterator(completers))
for (let cmpltr of completers)
{
let tmpCc = cmpltr(currentText, text) || {collection : null};
let collection = tmpCc.collection;
Expand All @@ -1749,7 +1749,7 @@ var prompt = function () {

let max = -1;

for (let [, c] in Iterator(collections))
for (let c of collections)
{
let first = c[0];

Expand Down Expand Up @@ -1797,8 +1797,8 @@ var prompt = function () {
context.text = left;
let tabs = getBrowser().mTabContainer.childNodes;
let collection = [[tab.image, tab.label, tab.linkedBrowser.contentDocument.URL]
for ([, tab] in Iterator(Array.slice(tabs)))];
let collection = [for (tab of Array.slice(tabs))
[tab.image, tab.label, tab.linkedBrowser.contentDocument.URL]];
let cc = completer.matcher.migemo(collection, {multiple:true})(left, whole);
cc.flags = [ICON | IGNORE, 0, 0];
Expand Down Expand Up @@ -1964,12 +1964,12 @@ var prompt = function () {
"watch" : undefined
};

for (let k in Iterator(objectPrototype, true))
for (let k of Object.keys(objectPrototype))
objectPrototype[k] = Object[k];

let functionPrototype = {__proto__ : objectPrototype};

for (let [, k] in Iterator(["apply", "call", "toSource", "toString", "valueOf"]))
for (let k of ["apply", "call", "toSource", "toString", "valueOf"])
functionPrototype[k] = Function[k];

let globalObjects = {
Expand All @@ -1994,11 +1994,11 @@ var prompt = function () {
URIError : []
};

for (let [objName, keys] in Iterator(globalObjects))
for (let [objName, keys] of util.keyValues(globalObjects))
{
globalObjects[objName] = {};

for ([, k] in Iterator(keys))
for (k of keys)
{
globalObjects[objName][k] = global[objName][k];
}
Expand Down Expand Up @@ -2214,8 +2214,7 @@ var prompt = function () {
if (!query)
{
cc.collection =
[getRow(root, k)
for (k in util.getAllPropertyNames(root))].sort(cmp);
[for (k of util.getAllPropertyNames(root)) getRow(root, k)].sort(cmp);
return cc;
}
else
Expand Down Expand Up @@ -2263,12 +2262,11 @@ var prompt = function () {
{
if (all)
{
cc.collection = [getRow(obj, k, prefix)
for (k in util.getAllPropertyNames(obj))].sort(cmp);
cc.collection = [for (k of util.getAllPropertyNames(obj)) getRow(obj, k, prefix)].sort(cmp);
}
else
{
let keys = [(k || "") for (k in util.getAllPropertyNames(obj))];
let keys = [for (k of util.getAllPropertyNames(obj)) (k || "")];
let matched = [];

// head
Expand All @@ -2289,7 +2287,7 @@ var prompt = function () {
return true;
});

cc.collection = [getRow(obj, k, prefix) for each (k in matched)];
cc.collection = [for (k of matched) getRow(obj, k, prefix)];
}
}

Expand Down Expand Up @@ -2828,7 +2826,7 @@ var prompt = function () {
hook.removeHook('KeySnailInitialized', onInitialized);
let displayHelpKey = [];

for (let [k, act] in Iterator(actionKeys.selector))
for (let [k, act] of util.keyValues(actionKeys.selector))
{
if (act === "prompt-display-keymap-help")
displayHelpKey.push(k);
Expand Down
6 changes: 3 additions & 3 deletions content/modules/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ var shell =
* @param {} b
*/
function implant(a, b) {
for (let [k, v] in Iterator(a))
for (let [k, v] of util.keyValues(a))
b[k] = v;

return b;
Expand Down Expand Up @@ -443,7 +443,7 @@ var shell =
argCount : "1",
options : [[["-prefix-arguments", "-pa"], option.INT, null]],
completer : function (args, extra) completer.matcher.header(
[[n, ext.description(n)] for (n in ext.exts)].sort(util.sortMultiple),
[for (n of Object.keys(ext.exts)) [n, ext.description(n)]].sort(util.sortMultiple),
{ style : ["", style.prompt.description] }
)(extra.left, extra.whole)
});
Expand Down Expand Up @@ -480,7 +480,7 @@ var shell =
// if user input
// "h" <TAB>
// returned item is will be "hoge".
for ([name, cmd] in Iterator(commands))
for (let [name, cmd] of util.keyValues(commands))
{
if (name.indexOf(left) === 0)
{
Expand Down
Loading

0 comments on commit 48f6a2a

Please sign in to comment.