1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-24 19:11:25 +02:00

Support Firefox 45 (without e10s).

This commit is contained in:
Kris Maglione
2015-12-19 20:09:04 -08:00
parent e3c3748511
commit bc9eb79fb3
41 changed files with 614 additions and 421 deletions
+10 -6
View File
@@ -56,7 +56,7 @@ function httpGet(uri) {
let moduleName; let moduleName;
let initialized = false; let initialized = false;
let addon = null; var addon = null;
let addonData = null; let addonData = null;
let basePath = null; let basePath = null;
let bootstrap; let bootstrap;
@@ -199,23 +199,27 @@ let JSMLoader = {
manager.unregisterFactory(factory.classID, factory); manager.unregisterFactory(factory.classID, factory);
}, },
Factory: function Factory(class_) ({ Factory(class_) {
__proto__: class_.prototype, let res = Object.create(class_.prototype);
createInstance: function (outer, iid) { res.createInstance = function (outer, iid) {
try { try {
if (outer != null) if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION; throw Cr.NS_ERROR_NO_AGGREGATION;
if (!class_.instance) if (!class_.instance)
class_.instance = new class_(); class_.instance = new class_();
return class_.instance.QueryInterface(iid); return class_.instance.QueryInterface(iid);
} }
catch (e) { catch (e) {
Cu.reportError(e); Cu.reportError(e);
throw e; throw e;
} }
} };
}),
return res;
},
registerFactory: function registerFactory(factory) { registerFactory: function registerFactory(factory) {
manager.registerFactory(factory.classID, manager.registerFactory(factory.classID,
+11 -10
View File
@@ -1,6 +1,6 @@
// Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org> // Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2010 by anekos <anekos@snca.net> // Copyright (c) 2010 by anekos <anekos@snca.net>
// Copyright (c) 2010-2014 Kris Maglione <maglione.k at Gmail> // Copyright (c) 2010-2015 Kris Maglione <maglione.k at Gmail>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -142,7 +142,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
*/ */
get: function (mode, lhs) { get: function (mode, lhs) {
let abbrevs = this._store[mode]; let abbrevs = this._store[mode];
return abbrevs && hasOwnProperty(abbrevs, lhs) ? abbrevs[lhs] return abbrevs && hasOwnProp(abbrevs, lhs) ? abbrevs[lhs]
: null; : null;
}, },
@@ -225,28 +225,29 @@ var Abbreviations = Module("abbreviations", {
nonkeyword: /[ "']/ nonkeyword: /[ "']/
}; };
this._match = util.regexp(literal(function () /* this._match = util.regexp(String.raw`
(^ | \s | <nonkeyword>) (<keyword>+ )$ | // full-id (^ | \s | <nonkeyword>) (<keyword>+ )$ | // full-id
(^ | \s | <keyword> ) (<nonkeyword>+ <keyword>)$ | // end-id (^ | \s | <keyword> ) (<nonkeyword>+ <keyword>)$ | // end-id
(^ | \s ) (\S* <nonkeyword> )$ // non-id (^ | \s ) (\S* <nonkeyword> )$ // non-id
*/$), "x", params); `, "x", params);
this._check = util.regexp(literal(function () /*
this._check = util.regexp(String.raw`
^ (?: ^ (?:
<keyword>+ | // full-id <keyword>+ | // full-id
<nonkeyword>+ <keyword> | // end-id <nonkeyword>+ <keyword> | // end-id
\S* <nonkeyword> // non-id \S* <nonkeyword> // non-id
) $ ) $
*/$), "x", params); `, "x", params);
}, },
get allHives() { return contexts.allGroups.abbrevs; }, get allHives() { return contexts.allGroups.abbrevs; },
get userHives() { return this.allHives.filter(h => h !== this.builtin); }, get userHives() { return this.allHives.filter(h => h !== this.builtin); },
get: deprecated("group.abbrevs.get", { get: function get() this.user.bound.get }), get: deprecated("group.abbrevs.get", { get: function get() { return this.user.bound.get; } }),
set: deprecated("group.abbrevs.set", { get: function set() this.user.bound.set }), set: deprecated("group.abbrevs.set", { get: function set() { return this.user.bound.set; } }),
remove: deprecated("group.abbrevs.remove", { get: function remove() this.user.bound.remove }), remove: deprecated("group.abbrevs.remove", { get: function remove() { return this.user.bound.remove; } }),
removeAll: deprecated("group.abbrevs.clear", { get: function removeAll() this.user.bound.clear }), removeAll: deprecated("group.abbrevs.clear", { get: function removeAll() { return this.user.bound.clear; } }),
/** /**
* Returns the abbreviation for the given *mode* if *text* matches the * Returns the abbreviation for the given *mode* if *text* matches the
+3 -3
View File
@@ -79,9 +79,9 @@ var AutoCommands = Module("autocommands", {
return contexts.allGroups.autocmd.filter(h => h._store.length); return contexts.allGroups.autocmd.filter(h => h._store.length);
}, },
add: deprecated("group.autocmd.add", { get: function add() autocommands.user.bound.add }), add: deprecated("group.autocmd.add", { get: function add() { return autocommands.user.bound.add; } }),
get: deprecated("group.autocmd.get", { get: function get() autocommands.user.bound.get }), get: deprecated("group.autocmd.get", { get: function get() { return autocommands.user.bound.get; } }),
remove: deprecated("group.autocmd.remove", { get: function remove() autocommands.user.bound.remove }), remove: deprecated("group.autocmd.remove", { get: function remove() { return autocommands.user.bound.remove; } }),
/** /**
* Lists all autocommands with a matching *event*, *regexp* and optionally * Lists all autocommands with a matching *event*, *regexp* and optionally
+9 -9
View File
@@ -77,7 +77,7 @@ var Bookmarks = Module("bookmarks", {
if (id != null) if (id != null)
var bmark = bookmarkcache.bookmarks[id]; var bmark = bookmarkcache.bookmarks[id];
else if (!force) { else if (!force) {
if (keyword && hasOwnProperty(bookmarkcache.keywords, keyword)) if (keyword && hasOwnProp(bookmarkcache.keywords, keyword))
bmark = bookmarkcache.keywords[keyword]; bmark = bookmarkcache.keywords[keyword];
else if (bookmarkcache.isBookmarked(uri)) else if (bookmarkcache.isBookmarked(uri))
for (bmark of bookmarkcache) for (bmark of bookmarkcache)
@@ -178,7 +178,7 @@ var Bookmarks = Module("bookmarks", {
} }
}, },
isBookmarked: deprecated("bookmarkcache.isBookmarked", { get: function isBookmarked() bookmarkcache.bound.isBookmarked }), isBookmarked: deprecated("bookmarkcache.isBookmarked", { get: function isBookmarked() { return bookmarkcache.bound.isBookmarked; } }),
/** /**
* Remove a bookmark or bookmarks. If *ids* is an array, removes the * Remove a bookmark or bookmarks. If *ids* is an array, removes the
@@ -213,7 +213,7 @@ var Bookmarks = Module("bookmarks", {
} }
}, },
getSearchEngines: deprecated("bookmarks.searchEngines", function getSearchEngines() this.searchEngines), getSearchEngines: deprecated("bookmarks.searchEngines", function getSearchEngines() { return this.searchEngines; }),
/** /**
* Returns a list of all visible search engines in the search * Returns a list of all visible search engines in the search
* services, augmented with keyword, title, and icon properties for * services, augmented with keyword, title, and icon properties for
@@ -228,7 +228,7 @@ var Bookmarks = Module("bookmarks", {
if (!alias) if (!alias)
alias = "search"; // for search engines which we can't find a suitable alias alias = "search"; // for search engines which we can't find a suitable alias
if (hasOwnProperty(aliases, alias)) if (hasOwnProp(aliases, alias))
alias += ++aliases[alias]; alias += ++aliases[alias];
else else
aliases[alias] = 0; aliases[alias] = 0;
@@ -252,10 +252,10 @@ var Bookmarks = Module("bookmarks", {
hasSuggestions: function hasSuggestions(engineName, query, callback) { hasSuggestions: function hasSuggestions(engineName, query, callback) {
const responseType = "application/x-suggestions+json"; const responseType = "application/x-suggestions+json";
if (hasOwnProperty(this.suggestionProviders, engineName)) if (hasOwnProp(this.suggestionProviders, engineName))
return true; return true;
let engine = hasOwnProperty(this.searchEngines, engineName) && this.searchEngines[engineName]; let engine = hasOwnProp(this.searchEngines, engineName) && this.searchEngines[engineName];
if (engine && engine.supportsResponseType(responseType)) if (engine && engine.supportsResponseType(responseType))
return true; return true;
@@ -281,10 +281,10 @@ var Bookmarks = Module("bookmarks", {
getSuggestions: function getSuggestions(engineName, query, callback) { getSuggestions: function getSuggestions(engineName, query, callback) {
const responseType = "application/x-suggestions+json"; const responseType = "application/x-suggestions+json";
if (hasOwnProperty(this.suggestionProviders, engineName)) if (hasOwnProp(this.suggestionProviders, engineName))
return this.suggestionProviders[engineName](query, callback); return this.suggestionProviders[engineName](query, callback);
let engine = hasOwnProperty(this.searchEngines, engineName) && this.searchEngines[engineName]; let engine = hasOwnProp(this.searchEngines, engineName) && this.searchEngines[engineName];
if (engine && engine.supportsResponseType(responseType)) if (engine && engine.supportsResponseType(responseType))
var queryURI = engine.getSubmission(query, responseType).uri.spec; var queryURI = engine.getSubmission(query, responseType).uri.spec;
@@ -347,7 +347,7 @@ var Bookmarks = Module("bookmarks", {
let [keyword, param] = util.split(query, " ", 2); let [keyword, param] = util.split(query, " ", 2);
param = param || ""; param = param || "";
var engine = hasOwnProperty(bookmarks.searchEngines, keyword) && bookmarks.searchEngines[keyword]; var engine = hasOwnProp(bookmarks.searchEngines, keyword) && bookmarks.searchEngines[keyword];
if (engine) { if (engine) {
if (engine.searchForm && !param) if (engine.searchForm && !param)
return engine.searchForm; return engine.searchForm;
+1 -1
View File
@@ -975,7 +975,7 @@ var CommandLine = Module("commandline", {
} }
}, },
updateOutputHeight: deprecated("mow.resize", function updateOutputHeight(open, extra) mow.resize(open, extra)), updateOutputHeight: deprecated("mow.resize", function updateOutputHeight(open, extra) { return mow.resize(open, extra); }),
withOutputToString: function withOutputToString(fn, self, ...args) { withOutputToString: function withOutputToString(fn, self, ...args) {
dactyl.registerObserver("echoLine", observe, true); dactyl.registerObserver("echoLine", observe, true);
+32 -20
View File
@@ -54,9 +54,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
delete window.liberator; delete window.liberator;
// Prevents box ordering bugs after our stylesheet is removed. // Prevents box ordering bugs after our stylesheet is removed.
styles.system.add("cleanup-sheet", config.styleableChrome, literal(function () /* styles.system.add("cleanup-sheet", config.styleableChrome, String.raw`
#TabsToolbar tab { display: none; } #TabsToolbar tab { display: none; }
*/$)); `);
styles.unregisterSheet("resource://dactyl-skin/dactyl.css"); styles.unregisterSheet("resource://dactyl-skin/dactyl.css");
DOM('#TabsToolbar tab', document).style.display; DOM('#TabsToolbar tab', document).style.display;
}, },
@@ -113,15 +113,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
} }
}, },
profileName: deprecated("config.profileName", { get: function profileName() config.profileName }), profileName: deprecated("config.profileName", { get: function profileName() { return config.profileName; } }),
/** /**
* @property {Modes.Mode} The current main mode. * @property {Modes.Mode} The current main mode.
* @see modes#mainModes * @see modes#mainModes
*/ */
mode: deprecated("modes.main", { mode: deprecated("modes.main", {
get: function mode() modes.main, get: function mode() { return modes.main; },
set: function mode(val) modes.main = val set: function mode(val) { modes.main = val; },
}), }),
getMenuItems: function getMenuItems(targetPath) { getMenuItems: function getMenuItems(targetPath) {
@@ -176,7 +176,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
this[v] = val[k]; this[v] = val[k];
}, },
version: deprecated("config.version", { get: function version() config.version }), version: deprecated("config.version", { get: function version() { return config.version; } }),
/** /**
* @property {Object} The map of command-line options. These are * @property {Object} The map of command-line options. These are
@@ -280,7 +280,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
for (let obj of results) { for (let obj of results) {
let res = dactyl.generateHelp(obj, null, null, true); let res = dactyl.generateHelp(obj, null, null, true);
if (!hasOwnProperty(help.tags, obj.helpTag)) if (!hasOwnProp(help.tags, obj.helpTag))
res[0][1].tag = obj.helpTag; res[0][1].tag = obj.helpTag;
yield res; yield res;
@@ -386,9 +386,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, },
dump: deprecated("util.dump", dump: deprecated("util.dump",
{ get: function dump() util.bound.dump }), { get: function dump() { return util.bound.dump; } }),
dumpStack: deprecated("util.dumpStack", dumpStack: deprecated("util.dumpStack",
{ get: function dumpStack() util.bound.dumpStack }), { get: function dumpStack() { return util.bound.dumpStack; } }),
/** /**
* Outputs a plain message to the command line. * Outputs a plain message to the command line.
@@ -638,8 +638,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
} }
}, },
help: deprecated("help.help", { get: function help() modules.help.bound.help }), help: deprecated("help.help", { get: function help() { return modules.help.bound.help; } }),
findHelp: deprecated("help.findHelp", { get: function findHelp() help.bound.findHelp }), findHelp: deprecated("help.findHelp", { get: function findHelp() { return help.bound.findHelp; } }),
/** /**
* @private * @private
@@ -762,7 +762,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
*/ */
_globalVariables: {}, _globalVariables: {},
globalVariables: deprecated(_("deprecated.for.theOptionsSystem"), { globalVariables: deprecated(_("deprecated.for.theOptionsSystem"), {
get: function globalVariables() this._globalVariables get: function globalVariables() { return this._globalVariables },
}), }),
loadPlugins: function loadPlugins(args, force) { loadPlugins: function loadPlugins(args, force) {
@@ -1053,15 +1053,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, this); }, this);
}, },
stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"), stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
urlish: Class.Memoize(() => util.regexp(literal(function () /* urlish: Class.Memoize(() => util.regexp(String.raw`
^ ( ^ (
<domain>+ (:\d+)? (/ .*) | <domain>+ (:\d+)? (/ .*) |
<domain>+ (:\d+) | <domain>+ (:\d+) |
<domain>+ \. [a-z0-9]+ | <domain>+ \. [a-z0-9]+ |
localhost localhost
) $ ) $
*/$), "ix", { `, "ix", {
domain: util.regexp(String.replace(literal(function () /* domain: util.regexp(String.raw`
[^ [^
U0000-U002c // U002d-U002e --. U0000-U002c // U002d-U002e --.
U002f // / U002f // /
@@ -1070,7 +1070,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
U005b-U0060 // U0061-U007a A-Z U005b-U0060 // U0061-U007a A-Z
U007b-U007f U007b-U007f
] ]
*/$), /U/g, "\\u"), "x") `.replace(/U/g, "\\u"), "x")
})), })),
pluginFiles: {}, pluginFiles: {},
@@ -1878,8 +1878,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
context.anchored = false; context.anchored = false;
context.keys = { context.keys = {
text: "dactylPath", text: "dactylPath",
description: function (item) item.getAttribute("label"), description: item => item.getAttribute("label"),
highlight: function (item) item.disabled ? "Disabled" : "" highlight: item => item.disabled ? "Disabled" : "",
}; };
context.generate = () => dactyl.menuItems; context.generate = () => dactyl.menuItems;
}; };
@@ -1888,7 +1888,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
context.title = ["Toolbar"]; context.title = ["Toolbar"];
context.keys = { context.keys = {
text: Dactyl.getToolbarName, text: Dactyl.getToolbarName,
description: function () "" description: () => "",
}; };
context.completions = config.toolbars; context.completions = config.toolbars;
}; };
@@ -1905,7 +1905,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
dactyl.log(_("dactyl.modulesLoaded"), 3); dactyl.log(_("dactyl.modulesLoaded"), 3);
userContext.DOM = Class("DOM", DOM, { init: function DOM_(sel, ctxt) DOM(sel, ctxt || buffer.focusedFrame.document) }); userContext.DOM = Class("DOM", DOM, {
init(sel, ctxt) {
return DOM(sel, ctxt || buffer.focusedFrame.document);
}
});
userContext.$ = modules.userContext.DOM; userContext.$ = modules.userContext.DOM;
// Hack: disable disabling of Personas in private windows. // Hack: disable disabling of Personas in private windows.
@@ -2038,6 +2043,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
statusline.update(); statusline.update();
dactyl.log(_("dactyl.initialized", config.appName), 0); dactyl.log(_("dactyl.initialized", config.appName), 0);
dactyl.initialized = true; dactyl.initialized = true;
util.delay(() => {
if (services.focus.activeWindow === window)
overlay.activeWindow = window;
util.flushLateMethods(dactyl);
});
} }
}); });
+2 -2
View File
@@ -75,7 +75,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
name = 0; name = 0;
if (name == "_") if (name == "_")
var res = null; var res = null;
else if (hasOwnProperty(this.selectionRegisters, name)) else if (hasOwnProp(this.selectionRegisters, name))
res = { text: dactyl.clipboardRead(this.selectionRegisters[name]) || "" }; res = { text: dactyl.clipboardRead(this.selectionRegisters[name]) || "" };
else if (!/^[0-9]$/.test(name)) else if (!/^[0-9]$/.test(name))
res = this.registers.get(name); res = this.registers.get(name);
@@ -113,7 +113,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
n = 0; n = 0;
if (n == "_") if (n == "_")
; ;
else if (hasOwnProperty(this.selectionRegisters, n)) else if (hasOwnProp(this.selectionRegisters, n))
dactyl.clipboardWrite(value.text, verbose, this.selectionRegisters[n]); dactyl.clipboardWrite(value.text, verbose, this.selectionRegisters[n]);
else if (!/^[0-9]$/.test(n)) else if (!/^[0-9]$/.test(n))
this.registers.set(n, value); this.registers.set(n, value);
+9 -9
View File
@@ -28,7 +28,7 @@ var EventHive = Class("EventHive", Contexts.Hive, {
else else
[self, events] = [event, event[callback || "events"]]; [self, events] = [event, event[callback || "events"]];
if (hasOwnProperty(events, "input") && !hasOwnProperty(events, "dactyl-input")) if (hasOwnProp(events, "input") && !hasOwnProp(events, "dactyl-input"))
events["dactyl-input"] = events.input; events["dactyl-input"] = events.input;
return [self, events]; return [self, events];
@@ -79,7 +79,7 @@ var EventHive = Class("EventHive", Contexts.Hive, {
let elem = args[0].get(); let elem = args[0].get();
if (target == null || elem == target if (target == null || elem == target
&& self == args[1].get() && self == args[1].get()
&& hasOwnProperty(events, args[2]) && hasOwnProp(events, args[2])
&& args[3].wrapped == events[args[2]] && args[3].wrapped == events[args[2]]
&& args[4] == capture) { && args[4] == capture) {
@@ -212,7 +212,7 @@ var Events = Module("events", {
}, },
get listen() { return this.builtin.bound.listen; }, get listen() { return this.builtin.bound.listen; },
addSessionListener: deprecated("events.listen", { get: function addSessionListener() this.listen }), addSessionListener: deprecated("events.listen", { get: function addSessionListener() { return this.listen; } }),
/** /**
* Wraps an event listener to ensure that errors are reported. * Wraps an event listener to ensure that errors are reported.
@@ -423,11 +423,11 @@ var Events = Module("events", {
return true; return true;
}, },
canonicalKeys: deprecated("DOM.Event.canonicalKeys", { get: function canonicalKeys() DOM.Event.bound.canonicalKeys }), canonicalKeys: deprecated("DOM.Event.canonicalKeys", { get: function canonicalKeys() { return DOM.Event.bound.canonicalKeys; } }),
create: deprecated("DOM.Event", function create() DOM.Event.apply(null, arguments)), create: deprecated("DOM.Event", function create() { return DOM.Event.apply(null, arguments); }),
dispatch: deprecated("DOM.Event.dispatch", function dispatch() apply(DOM.Event, "dispatch", arguments)), dispatch: deprecated("DOM.Event.dispatch", function dispatch() { return apply(DOM.Event, "dispatch", arguments); }),
fromString: deprecated("DOM.Event.parse", { get: function fromString() DOM.Event.bound.parse }), fromString: deprecated("DOM.Event.parse", { get: function fromString() { return DOM.Event.bound.parse; } }),
iterKeys: deprecated("DOM.Event.iterKeys", { get: function iterKeys() DOM.Event.bound.iterKeys }), iterKeys: deprecated("DOM.Event.iterKeys", { get: function iterKeys() { return DOM.Event.bound.iterKeys; } }),
toString: function toString() { toString: function toString() {
if (!arguments.length) if (!arguments.length)
@@ -1152,7 +1152,7 @@ var Events = Module("events", {
has: function (key) { has: function (key) {
return this.pass.has(key) || return this.pass.has(key) ||
hasOwnProperty(this.commandHive.stack.mappings, key); hasOwnProp(this.commandHive.stack.mappings, key);
}, },
get pass() { this.flush(); return this.pass; }, get pass() { this.flush(); return this.pass; },
+8 -8
View File
@@ -39,7 +39,7 @@ var Map = Class("Map", {
Object.freeze(this.modes); Object.freeze(this.modes);
if (info) { if (info) {
if (hasOwnProperty(Map.types, info.type)) if (hasOwnProp(Map.types, info.type))
this.update(Map.types[info.type]); this.update(Map.types[info.type]);
this.update(info); this.update(info);
} }
@@ -370,7 +370,7 @@ var Mappings = Module("mappings", {
get userHives() { return this.allHives.filter(h => h !== this.builtin); }, get userHives() { return this.allHives.filter(h => h !== this.builtin); },
expandLeader: deprecated("your brain", function expandLeader(keyString) keyString), expandLeader: deprecated("your brain", function expandLeader(keyString) { return keyString; }),
prefixes: Class.Memoize(function () { prefixes: Class.Memoize(function () {
let list = Array.map("CASM", s => s + "-"); let list = Array.map("CASM", s => s + "-");
@@ -415,11 +415,11 @@ var Mappings = Module("mappings", {
return this.iterate(modes.NORMAL); return this.iterate(modes.NORMAL);
}, },
getDefault: deprecated("mappings.builtin.get", function getDefault(mode, cmd) this.builtin.get(mode, cmd)), getDefault: deprecated("mappings.builtin.get", function getDefault(mode, cmd) { return this.builtin.get(mode, cmd); }),
getUserIterator: deprecated("mappings.user.iterator", function getUserIterator(modes) this.user.iterator(modes)), getUserIterator: deprecated("mappings.user.iterator", function getUserIterator(modes) { return this.user.iterator(modes); }),
hasMap: deprecated("group.mappings.has", function hasMap(mode, cmd) this.user.has(mode, cmd)), hasMap: deprecated("group.mappings.has", function hasMap(mode, cmd) { return this.user.has(mode, cmd); }),
remove: deprecated("group.mappings.remove", function remove(mode, cmd) this.user.remove(mode, cmd)), remove: deprecated("group.mappings.remove", function remove(mode, cmd) { return this.user.remove(mode, cmd); }),
removeAll: deprecated("group.mappings.clear", function removeAll(mode) this.user.clear(mode)), removeAll: deprecated("group.mappings.clear", function removeAll(mode) { return this.user.clear(mode); }),
/** /**
* Adds a new default key mapping. * Adds a new default key mapping.
@@ -839,7 +839,7 @@ var Mappings = Module("mappings", {
iterateIndex: function (args) { iterateIndex: function (args) {
let self = this; let self = this;
let prefix = /^[bCmn]$/.test(mode.char) ? "" : mode.char + "_"; let prefix = /^[bCmn]$/.test(mode.char) ? "" : mode.char + "_";
let haveTag = k => hasOwnProperty(help.tags, k); let haveTag = k => hasOwnProp(help.tags, k);
return ({ helpTag: prefix + map.name, __proto__: map } return ({ helpTag: prefix + map.name, __proto__: map }
for (map of self.iterate(args, true)) for (map of self.iterate(args, true))
+2 -2
View File
@@ -659,7 +659,7 @@ var Modes = Module("modes", {
return (this.value.find(v => val.some(m => m.name === v.mode)) return (this.value.find(v => val.some(m => m.name === v.mode))
|| { result: default_ }).result; || { result: default_ }).result;
return hasOwnProperty(this.valueMap, val) ? this.valueMap[val] : default_; return hasOwnProp(this.valueMap, val) ? this.valueMap[val] : default_;
}, },
setter: function (vals) { setter: function (vals) {
@@ -678,7 +678,7 @@ var Modes = Module("modes", {
validator: function validator(vals) { validator: function validator(vals) {
return vals.map(v => v.replace(/^!/, "")) return vals.map(v => v.replace(/^!/, ""))
.every(k => hasOwnProperty(this.values, k)); .every(k => hasOwnProp(this.values, k));
}, },
get values() { get values() {
+15 -5
View File
@@ -7,8 +7,22 @@
"use strict"; "use strict";
var MOW = Module("mow", { var MOW = Module("mow", {
init: function init() { init() {
let proxy = new Proxy(this, {
get(target, prop, receiver) {
if (prop in target)
return target[prop];
if (prop in Buffer)
return Buffer[prop].bind(Buffer, receiver.body);
},
});
proxy._init();
return proxy;
},
_init() {
this._resize = Timer(20, 400, function _resize() { this._resize = Timer(20, 400, function _resize() {
if (this.visible) if (this.visible)
this.resize(false); this.resize(false);
@@ -66,10 +80,6 @@ var MOW = Module("mow", {
}); });
}, },
__noSuchMethod__: function (meth, args) {
return apply(Buffer, meth, [this.body].concat(args));
},
get widget() { return this.widgets.multilineOutput; }, get widget() { return this.widgets.multilineOutput; },
widgets: Class.Memoize(function widgets() { widgets: Class.Memoize(function widgets() {
+13 -9
View File
@@ -37,27 +37,31 @@ var StatusLine = Module("statusline", {
config.tabbrowser.getStatusPanel().hidden = true; config.tabbrowser.getStatusPanel().hidden = true;
if (this.statusBar.localName == "toolbar") { if (this.statusBar.localName == "toolbar") {
styles.system.add("addon-bar", config.styleableChrome, literal(function () /* styles.system.add("addon-bar", config.styleableChrome, String.raw`
#status-bar, #dactyl-status-bar { margin-top: 0 !important; } #status-bar, #dactyl-status-bar { margin-top: 0 !important; }
#dactyl-status-bar { min-height: 0 !important; } #dactyl-status-bar { min-height: 0 !important; }
:-moz-any(#addon-bar, #dactyl-addon-bar) > statusbar { -moz-box-flex: 1 } :-moz-any(#addon-bar, #dactyl-addon-bar) > statusbar { -moz-box-flex: 1 }
:-moz-any(#addon-bar, #dactyl-addon-bar) > xul|toolbarspring { visibility: collapse; } :-moz-any(#addon-bar, #dactyl-addon-bar) > xul|toolbarspring { visibility: collapse; }
#browser-bottombox>#addon-bar > #addonbar-closebutton { visibility: collapse; } #browser-bottombox>#addon-bar > #addonbar-closebutton { visibility: collapse; }
*/$)); `);
overlay.overlayWindow(window, { overlay.overlayWindow(window, {
append: [ append: [
["statusbar", { id: this._statusLine.id, ordinal: "0" }]] ["statusbar", { id: this._statusLine.id, ordinal: "0" }]]
}); });
highlight.loadCSS(util.compileMacro(literal(function () /* let padding = "";
if (config.OS.isMacOSX)
padding = "padding-right: 10px !important;";
highlight.loadCSS(String.raw`
!AddonBar;#browser-bottombox>#addon-bar,#dactyl-addon-bar { !AddonBar;#browser-bottombox>#addon-bar,#dactyl-addon-bar {
padding-left: 0 !important; padding-left: 0 !important;
padding-top: 0 !important; padding-top: 0 !important;
padding-bottom: 0 !important; padding-bottom: 0 !important;
min-height: 18px !important; min-height: 18px !important;
-moz-appearance: none !important; -moz-appearance: none !important;
<padding> ${padding}
} }
!AddonButton;#browser-bottombox>#addon-bar xul|toolbarbutton, #dactyl-addon-bar xul|toolbarbutton { !AddonButton;#browser-bottombox>#addon-bar xul|toolbarbutton, #dactyl-addon-bar xul|toolbarbutton {
-moz-appearance: none !important; -moz-appearance: none !important;
@@ -67,12 +71,12 @@ var StatusLine = Module("statusline", {
color: inherit !important; color: inherit !important;
} }
AddonButton:not(:hover) background: transparent; AddonButton:not(:hover) background: transparent;
*/$))({ padding: config.OS.isMacOSX ? "padding-right: 10px !important;" : "" })); `);
if (document.getElementById("appmenu-button")) if (document.getElementById("appmenu-button"))
highlight.loadCSS(literal(function () /* highlight.loadCSS(String.raw`
AppmenuButton min-width: 0 !important; padding: 0 .5em !important; AppmenuButton min-width: 0 !important; padding: 0 .5em !important;
*/$)); `);
} }
let prepend = [ let prepend = [
@@ -239,8 +243,8 @@ var StatusLine = Module("statusline", {
this.updateZoomLevel(); this.updateZoomLevel();
}, },
unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() util.unsafeURI }), unsafeURI: deprecated("util.unsafeURI", { get: function unsafeURI() { return util.unsafeURI; } }),
losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() apply(util, "losslessDecodeURI", arguments)), losslessDecodeURI: deprecated("util.losslessDecodeURI", function losslessDecodeURI() { return apply(util, "losslessDecodeURI", arguments); }),
/** /**
* Update the URL displayed in the status line. Also displays status * Update the URL displayed in the status line. Also displays status
+10 -7
View File
@@ -36,9 +36,11 @@ var Tabs = Module("tabs", {
tabs.switchTo(event.originalTarget.getAttribute("identifier")); tabs.switchTo(event.originalTarget.getAttribute("identifier"));
}; };
this.tabBinding = styles.system.add("tab-binding", "chrome://browser/content/browser.xul", literal(function () /* this.tabBinding = styles.system.add(
"tab-binding", "chrome://browser/content/browser.xul",
String.raw`
xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab) !important; } xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab) !important; }
*/$).replace(/tab-./g, m => config.OS.isMacOSX ? "tab-mac" : m), `,
false, true); false, true);
this.timeout(function () { this.timeout(function () {
@@ -133,10 +135,11 @@ var Tabs = Module("tabs", {
* in the current window. * in the current window.
*/ */
get browsers() { get browsers() {
let browsers = config.tabbrowser.browsers; return function* () {
for (let i = 0; i < browsers.length; i++) for (let [i, browser] of config.tabbrowser.browsers.entries())
if (browsers[i] !== undefined) // Bug in Google's Page Speed add-on. if (browser !== undefined) // Bug in Google's Page Speed add-on.
yield [i, browsers[i]]; yield [i, browser];
}();
}, },
/** /**
@@ -1064,7 +1067,7 @@ var Tabs = Module("tabs", {
tabs.getGroups(); tabs.getGroups();
tabs[visible ? "visibleTabs" : "allTabs"].forEach(function (tab, i) { tabs[visible ? "visibleTabs" : "allTabs"].forEach(function (tab, i) {
let group = (tab.tabItem || tab._tabViewTabItem || defItem).parent || defItem.parent; let group = (tab.tabItem || tab._tabViewTabItem || defItem).parent || defItem.parent;
if (!hasOwnProperty(tabGroups, group.id)) if (!hasOwnProp(tabGroups, group.id))
tabGroups[group.id] = [group.getTitle(), []]; tabGroups[group.id] = [group.getTitle(), []];
group = tabGroups[group.id]; group = tabGroups[group.id];
+1 -1
View File
@@ -167,7 +167,7 @@ var Addon = Class("Addon", {
}, },
commandAllowed: function commandAllowed(cmd) { commandAllowed: function commandAllowed(cmd) {
util.assert(hasOwnProperty(actions, cmd), util.assert(hasOwnProp(actions, cmd),
_("addon.unknownCommand")); _("addon.unknownCommand"));
let action = actions[cmd]; let action = actions[cmd];
+60 -36
View File
@@ -26,10 +26,12 @@ try {
catch (e) {} catch (e) {}
let objproto = Object.prototype; let objproto = Object.prototype;
let { __lookupGetter__, __lookupSetter__, __defineGetter__, __defineSetter__, var { __lookupGetter__, __lookupSetter__, __defineGetter__, __defineSetter__,
hasOwnProperty, propertyIsEnumerable } = objproto; hasOwnProperty, propertyIsEnumerable } = objproto;
hasOwnProperty = Function.call.bind(hasOwnProperty); var hasOwnProp = Function.call.bind(hasOwnProperty);
hasOwnProperty = hasOwnProp;
propertyIsEnumerable = Function.call.bind(propertyIsEnumerable); propertyIsEnumerable = Function.call.bind(propertyIsEnumerable);
function require(module_, target) { function require(module_, target) {
@@ -43,7 +45,7 @@ function lazyRequire(module, names, target) {
memoize(target || this, name, name => require(module)[name]); memoize(target || this, name, name => require(module)[name]);
} }
let jsmodules = { lazyRequire: lazyRequire }; var jsmodules = { lazyRequire: lazyRequire };
jsmodules.jsmodules = jsmodules; jsmodules.jsmodules = jsmodules;
function toString() { function toString() {
@@ -62,10 +64,10 @@ function objToString(obj) {
} }
} }
let use = {}; var use = {};
let loaded = {}; var loaded = {};
let currentModule; var currentModule;
let global = this; var global = this;
function defineModule(name, params, module) { function defineModule(name, params, module) {
if (!module) if (!module)
module = this; module = this;
@@ -203,6 +205,7 @@ defineModule("base", {
"deprecated", "deprecated",
"endModule", "endModule",
"hasOwnProperty", "hasOwnProperty",
"hasOwnProp",
"identity", "identity",
"isArray", "isArray",
"isGenerator", "isGenerator",
@@ -238,9 +241,7 @@ if (typeof Symbol == "undefined")
iterator: "@@iterator" iterator: "@@iterator"
}; };
literal.files = {}; let literal_ = function literal(comment) {
literal.locations = {};
function literal(comment) {
if (comment) if (comment)
return /^function.*?\/\*([^]*)\*\/(?:\/\* use strict \*\/)\s*\S$/.exec(comment)[1]; return /^function.*?\/\*([^]*)\*\/(?:\/\* use strict \*\/)\s*\S$/.exec(comment)[1];
@@ -248,6 +249,9 @@ function literal(comment) {
while (caller && caller.language != 2) while (caller && caller.language != 2)
caller = caller.caller; caller = caller.caller;
// Immediate caller is the `deprecate` helper.
caller = caller.caller;
let file = caller.filename.replace(/.* -> /, ""); let file = caller.filename.replace(/.* -> /, "");
let key = "literal:" + file + ":" + caller.lineNumber; let key = "literal:" + file + ":" + caller.lineNumber;
return cache.get(key, function() { return cache.get(key, function() {
@@ -258,7 +262,15 @@ function literal(comment) {
".*literal\\(/\\*([^]*?)\\*/\\)").exec(source); ".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);
return match[1]; return match[1];
}); });
} };
literal_.files = {};
literal_.locations = {};
// This needs to happen after `files` and `locations` have been defined
// as properties of the real `literal` function.
var literal = deprecated("template strings", literal_);
literal.files = literal_.files;
literal.locations = literal_.locations;
function apply(obj, meth, args) { function apply(obj, meth, args) {
// The function's own apply method breaks in strange ways // The function's own apply method breaks in strange ways
@@ -403,7 +415,7 @@ function keys(obj) {
return iter(obj.keys()); return iter(obj.keys());
return iter(k for (k in obj) return iter(k for (k in obj)
if (hasOwnProperty(obj, k))); if (hasOwnProp(obj, k)));
} }
/** /**
@@ -424,7 +436,7 @@ function values(obj) {
return iter(obj[Symbol.iterator]()); return iter(obj[Symbol.iterator]());
return iter(obj[k] for (k in obj) return iter(obj[k] for (k in obj)
if (hasOwnProperty(obj, k))); if (hasOwnProp(obj, k)));
} }
var RealSet = Set; var RealSet = Set;
@@ -513,7 +525,7 @@ Set.has = deprecated("hasOwnProperty or Set#has",
if (isinstance(set, ["Set"])) if (isinstance(set, ["Set"]))
return set.has(key); return set.has(key);
return hasOwnProperty(set, key) && return hasOwnProp(set, key) &&
propertyIsEnumerable(set, key); propertyIsEnumerable(set, key);
})); }));
/** /**
@@ -807,13 +819,17 @@ function memoize(obj, key, getter) {
function update(target) { function update(target) {
for (let i = 1; i < arguments.length; i++) { for (let i = 1; i < arguments.length; i++) {
let src = arguments[i]; let src = arguments[i];
Object.getOwnPropertyNames(src || {}).forEach(function (k) { Object.getOwnPropertyNames(src || {}).forEach(function (k) {
let desc = Object.getOwnPropertyDescriptor(src, k); let desc = Object.getOwnPropertyDescriptor(src, k);
if (desc.value instanceof Class.Property) if (desc.value instanceof Class.Property)
desc = desc.value.init(k, target) || desc.value; desc = desc.value.init(k, target) || desc.value;
try { try {
if (callable(desc.value) && target.__proto__) { if (callable(desc.value) &&
Cu.getClassName(desc.value, true) != "Proxy" &&
Object.getPrototypeOf(target)) {
let func = desc.value.wrapped || desc.value; let func = desc.value.wrapped || desc.value;
if (!func.superapply) { if (!func.superapply) {
func.__defineGetter__("super", function get_super() { func.__defineGetter__("super", function get_super() {
@@ -836,7 +852,9 @@ function update(target) {
Object.defineProperty(target, k, desc); Object.defineProperty(target, k, desc);
} }
catch (e) {} catch (e) {
dump("Hmm... " + e + "\n" + (e && e.stack || new Error().stack) + "\n");
}
}); });
} }
return target; return target;
@@ -1184,7 +1202,7 @@ for (let name of properties(Class.prototype)) {
var closureHooks = { var closureHooks = {
get: function closure_get(target, prop) { get: function closure_get(target, prop) {
if (hasOwnProperty(target._closureCache, prop)) if (hasOwnProp(target._closureCache, prop))
return target._closureCache[prop]; return target._closureCache[prop];
let p = target[prop]; let p = target[prop];
@@ -1347,7 +1365,9 @@ Module.INIT = {
module.isLocalModule = true; module.isLocalModule = true;
modules.jsmodules[this.constructor.className] = module; modules.jsmodules[this.constructor.className] = module;
locals.reverse().forEach((fn, i) => { update(objs[i], fn.apply(module, args)); }); locals.reverse().forEach((fn, i) => {
update(objs[i], fn.apply(module, args));
});
memoize(module, "closure", Class.makeClosure); memoize(module, "closure", Class.makeClosure);
module.instance = module; module.instance = module;
@@ -1544,7 +1564,7 @@ function UTF8(str) {
} }
} }
var octal = deprecated("octal integer literals", function octal(decimal) parseInt(decimal, 8)); var octal = deprecated("octal integer literals", function octal(decimal) { return parseInt(decimal, 8); });
/** /**
* Iterates over an arbitrary object. The following iterator types are * Iterates over an arbitrary object. The following iterator types are
@@ -1777,8 +1797,8 @@ update(iter, {
} }
}); });
const Iter = Class("Iter", { var Iter = Class("Iter", {
init: function init(iter) { init(iter) {
this.iter = iter; this.iter = iter;
if (!(Symbol.iterator in iter) && "__iterator__" in iter) if (!(Symbol.iterator in iter) && "__iterator__" in iter)
this.iter = iter.__iterator__(); this.iter = iter.__iterator__();
@@ -1789,11 +1809,11 @@ const Iter = Class("Iter", {
}; };
}, },
next: function next() this.iter.next(), next() { return this.iter.next() },
send: function send() apply(this.iter, "send", arguments), send() { return apply(this.iter, "send", arguments) },
"@@iterator": function () this.iter, "@@iterator": function () { return this.iter },
__iterator__: function () { __iterator__: function () {
Cu.reportError( Cu.reportError(
@@ -1837,7 +1857,7 @@ var Ary = Class("Ary", Array, {
if (prop == "array") if (prop == "array")
return target; return target;
if (hasOwnProperty(Ary, prop) && callable(Ary[prop])) if (hasOwnProp(Ary, prop) && callable(Ary[prop]))
return arrayWrap(Ary[prop].bind(Ary, target)); return arrayWrap(Ary[prop].bind(Ary, target));
let p = target[prop]; let p = target[prop];
@@ -1882,7 +1902,7 @@ var Ary = Class("Ary", Array, {
* @param {Array} ary * @param {Array} ary
* @returns {Array} * @returns {Array}
*/ */
compact: function compact(ary) ary.filter(item => item != null), compact(ary) { return ary.filter(item => item != null) },
/** /**
* Returns true if each element of ary1 is equal to the * Returns true if each element of ary1 is equal to the
@@ -1892,8 +1912,10 @@ var Ary = Class("Ary", Array, {
* @param {Array} ary2 * @param {Array} ary2
* @returns {boolean} * @returns {boolean}
*/ */
equals: function (ary1, ary2) equals(ary1, ary2) {
ary1.length === ary2.length && Array.every(ary1, (e, i) => e === ary2[i]), return (ary1.length === ary2.length &&
Array.every(ary1, (e, i) => e === ary2[i]));
},
/** /**
* Flattens an array, such that all elements of the array are * Flattens an array, such that all elements of the array are
@@ -1903,7 +1925,11 @@ var Ary = Class("Ary", Array, {
* @param {Array} ary * @param {Array} ary
* @returns {Array} * @returns {Array}
*/ */
flatten: function flatten(ary) ary.length ? Array.prototype.concat.apply([], ary) : [], flatten(ary) {
if (ary.length)
return [].concat(...ary);
return [];
},
/** /**
* Returns an Iterator for an array's values. * Returns an Iterator for an array's values.
@@ -1980,11 +2006,10 @@ var Ary = Class("Ary", Array, {
} }
}); });
/* Make Minefield not explode, because Minefield exploding is not fun. */
let iterProto = Iter.prototype; let iterProto = Iter.prototype;
Object.keys(iter).forEach(function (k) { Object.keys(iter).forEach(function (k) {
iterProto[k] = function (...args) { iterProto[k] = function (...args) {
let res = apply(iter, k, [this].concat(args)); let res = iter[k](this, ...args);
if (k == "toArray") if (k == "toArray")
return res; return res;
@@ -1999,7 +2024,7 @@ Object.keys(iter).forEach(function (k) {
Object.keys(Ary).forEach(function (k) { Object.keys(Ary).forEach(function (k) {
if (!(k in iterProto)) if (!(k in iterProto))
iterProto[k] = function (...args) { iterProto[k] = function (...args) {
let res = apply(Ary, k, [this.toArray()].concat(args)); let res = Ary[k]([...this], ...args);
if (isArray(res)) if (isArray(res))
return Ary(res); return Ary(res);
@@ -2012,9 +2037,8 @@ Object.keys(Ary).forEach(function (k) {
Object.getOwnPropertyNames(Array.prototype).forEach(function (k) { Object.getOwnPropertyNames(Array.prototype).forEach(function (k) {
if (!(k in iterProto) && callable(Array.prototype[k])) if (!(k in iterProto) && callable(Array.prototype[k]))
iterProto[k] = function () { iterProto[k] = function (...args) {
let ary = this.toArray(); let res = [...this][k](...args);
let res = apply(ary, k, arguments);
if (isArray(res)) if (isArray(res))
return Ary(res); return Ary(res);
@@ -2024,7 +2048,7 @@ Object.getOwnPropertyNames(Array.prototype).forEach(function (k) {
}); });
Object.defineProperty(Class.prototype, "closure", Object.defineProperty(Class.prototype, "closure",
deprecated("bound", { get: function closure() this.bound })); deprecated("bound", { get: function closure() { return this.bound; } }));
if (false) if (false)
var array = Class("array", Ary, { var array = Class("array", Ary, {
+16 -14
View File
@@ -385,7 +385,8 @@ var Buffer = Module("Buffer", {
* @returns {string} * @returns {string}
*/ */
get currentWord() { return Buffer.currentWord(this.focusedFrame); }, get currentWord() { return Buffer.currentWord(this.focusedFrame); },
getCurrentWord: deprecated("buffer.currentWord", function getCurrentWord() Buffer.currentWord(this.focusedFrame, true)), getCurrentWord: deprecated("buffer.currentWord",
function getCurrentWord() { return Buffer.currentWord(this.focusedFrame, true); }),
/** /**
* Returns true if a scripts are allowed to focus the given input * Returns true if a scripts are allowed to focus the given input
@@ -770,7 +771,8 @@ var Buffer = Module("Buffer", {
* *
* @param {Node} elem The context element. * @param {Node} elem The context element.
*/ */
openContextMenu: deprecated("DOM#contextmenu", function openContextMenu(elem) DOM(elem).contextmenu()), openContextMenu: deprecated("DOM#contextmenu",
function openContextMenu(elem) { return DOM(elem).contextmenu(); }),
/** /**
* Saves a page link to disk. * Saves a page link to disk.
@@ -1415,14 +1417,14 @@ var Buffer = Module("Buffer", {
}, },
getAllFrames: deprecated("buffer.allFrames", "allFrames"), getAllFrames: deprecated("buffer.allFrames", "allFrames"),
scrollTop: deprecated("buffer.scrollToPercent", function scrollTop() this.scrollToPercent(null, 0)), scrollTop: deprecated("buffer.scrollToPercent", function scrollTop() { return this.scrollToPercent(null, 0); }),
scrollBottom: deprecated("buffer.scrollToPercent", function scrollBottom() this.scrollToPercent(null, 100)), scrollBottom: deprecated("buffer.scrollToPercent", function scrollBottom() { return this.scrollToPercent(null, 100); }),
scrollStart: deprecated("buffer.scrollToPercent", function scrollStart() this.scrollToPercent(0, null)), scrollStart: deprecated("buffer.scrollToPercent", function scrollStart() { return this.scrollToPercent(0, null); }),
scrollEnd: deprecated("buffer.scrollToPercent", function scrollEnd() this.scrollToPercent(100, null)), scrollEnd: deprecated("buffer.scrollToPercent", function scrollEnd() { return this.scrollToPercent(100, null); }),
scrollColumns: deprecated("buffer.scrollHorizontal", function scrollColumns(cols) this.scrollHorizontal("columns", cols)), scrollColumns: deprecated("buffer.scrollHorizontal", function scrollColumns(cols) { return this.scrollHorizontal("columns", cols); }),
scrollPages: deprecated("buffer.scrollHorizontal", function scrollPages(pages) this.scrollVertical("pages", pages)), scrollPages: deprecated("buffer.scrollHorizontal", function scrollPages(pages) { return this.scrollVertical("pages", pages); }),
scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) this.win.scrollTo(x, y)), scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) { return this.win.scrollTo(x, y); }),
textZoom: deprecated("buffer.zoomValue/buffer.fullZoom", function textZoom() this.contentViewer.markupDocumentViewer.textZoom * 100) textZoom: deprecated("buffer.zoomValue/buffer.fullZoom", function textZoom() { return this.contentViewer.markupDocumentViewer.textZoom * 100; }),
}, { }, {
/** /**
* The pattern used to search for a scrollable element when we have * The pattern used to search for a scrollable element when we have
@@ -1508,9 +1510,9 @@ var Buffer = Module("Buffer", {
get ZOOM_MAX() { return prefs.get("zoom.maxPercent"); }, get ZOOM_MAX() { return prefs.get("zoom.maxPercent"); },
setZoom: deprecated("buffer.setZoom", setZoom: deprecated("buffer.setZoom",
function setZoom(...args) apply(overlay.activeModules.buffer, "setZoom", args)), function setZoom(...args) { return apply(overlay.activeModules.buffer, "setZoom", args); }),
bumpZoomLevel: deprecated("buffer.bumpZoomLevel", bumpZoomLevel: deprecated("buffer.bumpZoomLevel",
function bumpZoomLevel(...args) apply(overlay.activeModules.buffer, "bumpZoomLevel", args)), function bumpZoomLevel(...args) { return apply(overlay.activeModules.buffer, "bumpZoomLevel", args); }),
/** /**
* Returns the currently selected word in *win*. If the selection is * Returns the currently selected word in *win*. If the selection is
@@ -1585,9 +1587,9 @@ var Buffer = Module("Buffer", {
}, },
findScrollableWindow: deprecated("buffer.findScrollableWindow", findScrollableWindow: deprecated("buffer.findScrollableWindow",
function findScrollableWindow() apply(overlay.activeModules, "findScrollableWindow", arguments)), function findScrollableWindow() { return apply(overlay.activeModules, "findScrollableWindow", arguments); }),
findScrollable: deprecated("buffer.findScrollable", findScrollable: deprecated("buffer.findScrollable",
function findScrollable() apply(overlay.activeModules, "findScrollable", arguments)), function findScrollable() { return apply(overlay.activeModules, "findScrollable", arguments); }),
isScrollable: function isScrollable(elem, dir, horizontal) { isScrollable: function isScrollable(elem, dir, horizontal) {
if (!DOM(elem).isScrollable(horizontal ? "horizontal" : "vertical")) if (!DOM(elem).isScrollable(horizontal ? "horizontal" : "vertical"))
+4 -4
View File
@@ -207,7 +207,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
return cache.force(name, true); return cache.force(name, true);
} }
if (hasOwnProperty(this.providers, name)) { if (hasOwnProp(this.providers, name)) {
util.assert(!this.providing.add(name), util.assert(!this.providing.add(name),
"Already generating cache for " + name, "Already generating cache for " + name,
false); false);
@@ -238,7 +238,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
if (this.storage.has(name)) if (this.storage.has(name))
return this.storage.get(name); return this.storage.get(name);
if (callback && !(hasOwnProperty(this.providers, name) || if (callback && !(hasOwnProp(this.providers, name) ||
this.localProviders.has(name))) this.localProviders.has(name)))
this.register(name, callback, long); this.register(name, callback, long);
@@ -249,14 +249,14 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
}, },
_has: function _has(name) { _has: function _has(name) {
return hasOwnProperty(this.providers, name) || return hasOwnProp(this.providers, name) ||
this.storage.has(name); this.storage.has(name);
}, },
has: function has(name) { has: function has(name) {
return [this.globalProviders, this.localProviders] return [this.globalProviders, this.localProviders]
.some(obj => isinstance(obj, ["Set"]) ? obj.has(name) .some(obj => isinstance(obj, ["Set"]) ? obj.has(name)
: hasOwnProperty(obj, name)); : hasOwnProp(obj, name));
}, },
register: function register(name, callback, long) { register: function register(name, callback, long) {
+52 -22
View File
@@ -349,8 +349,8 @@ var Command = Class("Command", {
explicitOpts: Class.Memoize(() => ({})), explicitOpts: Class.Memoize(() => ({})),
has: function AP_has(opt) { has: function AP_has(opt) {
return hasOwnProperty(this.explicitOpts, opt) || return hasOwnProp(this.explicitOpts, opt) ||
typeof opt === "number" && hasOwnProperty(this, opt); typeof opt === "number" && hasOwnProp(this, opt);
}, },
get literalArg() { get literalArg() {
@@ -465,14 +465,36 @@ var Command = Class("Command", {
// Prototype. // Prototype.
var Ex = Module("Ex", { var Ex = Module("Ex", {
Local: function Local(dactyl, modules, window) { Local(dactyl, modules, window) {
return { return {
init() {},
get commands() { return modules.commands; }, get commands() { return modules.commands; },
get context() { return modules.contexts.context; } get context() { return modules.contexts.context; }
}; };
}, },
_args: function E_args(cmd, args) { commands: null,
init() {
let proxy = new Proxy(this, {
get(target, prop, receiver) {
if (prop === "isProxy")
return [true, receiver === proxy].join(",");
if (prop in target || receiver === proxy)
return target[prop];
return function (...args) {
return this._run(prop)(...args);
};
},
});
return proxy;
},
_args(cmd, args) {
args = Array.slice(args); args = Array.slice(args);
let res = cmd.newArgs({ context: this.context }); let res = cmd.newArgs({ context: this.context });
@@ -492,12 +514,13 @@ var Ex = Module("Ex", {
Class.replaceProperty(res, opt.names[0], val); Class.replaceProperty(res, opt.names[0], val);
res.explicitOpts[opt.names[0]] = val; res.explicitOpts[opt.names[0]] = val;
} }
for (let [i, val] of Ary.iterItems(args)) for (let [i, val] of Ary.iterItems(args))
res[i] = String(val); res[i] = String(val);
return res; return res;
}, },
_complete: function E_complete(cmd) { _complete(cmd) {
return (context, func, obj, args) => { return (context, func, obj, args) => {
args = this._args(cmd, args); args = this._args(cmd, args);
args.completeArg = args.length - 1; args.completeArg = args.length - 1;
@@ -506,7 +529,7 @@ var Ex = Module("Ex", {
}; };
}, },
_run: function E_run(name) { _run(name) {
const self = this; const self = this;
let cmd = this.commands.get(name); let cmd = this.commands.get(name);
util.assert(cmd, _("command.noSuch")); util.assert(cmd, _("command.noSuch"));
@@ -519,10 +542,6 @@ var Ex = Module("Ex", {
dactylCompleter: self._complete(cmd) dactylCompleter: self._complete(cmd)
}); });
}, },
__noSuchMethod__: function __noSuchMethod__(meth, args) {
return this._run(meth).apply(this, args);
}
}); });
var CommandHive = Class("CommandHive", Contexts.Hive, { var CommandHive = Class("CommandHive", Contexts.Hive, {
@@ -616,7 +635,18 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
} }
for (let name of names) { for (let name of names) {
ex.__defineGetter__(name, function () { return this._run(name); }); if (false)
// For some reason, the `this` object of the getter gets
// mutilated if we do this in recent Firefox versions.
// Just rely on the proxy for now.
Object.defineProperty(ex, name, {
configurable: true,
enumerable: true,
get() {
return this._run(name);
},
});
if (name in this._map && !this._map[name].isPlaceholder) if (name in this._map && !this._map[name].isPlaceholder)
this.remove(name); this.remove(name);
} }
@@ -888,9 +918,9 @@ var Commands = Module("commands", {
extra.definedAt = contexts.getCaller(caller); extra.definedAt = contexts.getCaller(caller);
return apply(group, "add", arguments); return apply(group, "add", arguments);
}, },
addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() this.user.bound._add }), addUserCommand: deprecated("group.commands.add", { get: function addUserCommand() { return this.user.bound._add } }),
getUserCommands: deprecated("iter(group.commands)", function getUserCommands() iter(this.user).toArray()), getUserCommands: deprecated("iter(group.commands)", function getUserCommands() { return iter(this.user).toArray(); }),
removeUserCommand: deprecated("group.commands.remove", { get: function removeUserCommand() this.user.bound.remove }), removeUserCommand: deprecated("group.commands.remove", { get: function removeUserCommand() { return this.user.bound.remove; } }),
/** /**
* Returns the specified command invocation object serialized to * Returns the specified command invocation object serialized to
@@ -1074,7 +1104,7 @@ var Commands = Module("commands", {
let matchOpts = function matchOpts(arg) { let matchOpts = function matchOpts(arg) {
// Push possible option matches into completions // Push possible option matches into completions
if (complete && !onlyArgumentsRemaining) if (complete && !onlyArgumentsRemaining)
completeOpts = options.filter(opt => (opt.multiple || !hasOwnProperty(args, opt.names[0]))); completeOpts = options.filter(opt => (opt.multiple || !hasOwnProp(args, opt.names[0])));
}; };
let resetCompletions = function resetCompletions() { let resetCompletions = function resetCompletions() {
completeOpts = null; completeOpts = null;
@@ -1306,14 +1336,14 @@ var Commands = Module("commands", {
} }
}, },
nameRegexp: util.regexp(literal(function () /* nameRegexp: util.regexp(String.raw`
[^ [^
0-9 0-9
<forbid> <forbid>
] ]
[^ <forbid> ]* [^ <forbid> ]*
*/$), "gx", { `, "gx", {
forbid: util.regexp(String.replace(literal(function () /* forbid: util.regexp(String.replace(String.raw`
U0000-U002c // U002d - U0000-U002c // U002d -
U002e-U002f U002e-U002f
U003a-U0040 // U0041-U005a a-z U003a-U0040 // U0041-U005a a-z
@@ -1336,7 +1366,7 @@ var Commands = Module("commands", {
Ufe70-Ufeff // Arabic Presentation Forms-B Ufe70-Ufeff // Arabic Presentation Forms-B
Uff00-Uffef // Halfwidth and Fullwidth Forms Uff00-Uffef // Halfwidth and Fullwidth Forms
Ufff0-Uffff // Specials Ufff0-Uffff // Specials
*/$), /U/g, "\\u"), "x") `, /U/g, "\\u"), "x")
}), }),
validName: Class.Memoize(function validName() { validName: Class.Memoize(function validName() {
@@ -1344,7 +1374,7 @@ var Commands = Module("commands", {
}), }),
commandRegexp: Class.Memoize(function commandRegexp() { commandRegexp: Class.Memoize(function commandRegexp() {
return util.regexp(literal(function () /* return util.regexp(String.raw`
^ ^
(?P<spec> (?P<spec>
(?P<prespace> [:\s]*) (?P<prespace> [:\s]*)
@@ -1359,7 +1389,7 @@ var Commands = Module("commands", {
(?:. | \n)*? (?:. | \n)*?
)? )?
$ $
*/$), "x", { `, "x", {
name: this.nameRegexp name: this.nameRegexp
}); });
}), }),
@@ -1832,7 +1862,7 @@ var Commands = Module("commands", {
iterateIndex: function (args) { iterateIndex: function (args) {
let tags = help.tags; let tags = help.tags;
return this.iterate(args).filter(cmd => (cmd.hive === commands.builtin || return this.iterate(args).filter(cmd => (cmd.hive === commands.builtin ||
hasOwnProperty(tags, cmd.helpTag))); hasOwnProp(tags, cmd.helpTag)));
}, },
format: { format: {
headings: ["Command", "Group", "Description"], headings: ["Command", "Group", "Description"],
+9 -5
View File
@@ -222,9 +222,13 @@ var CompletionContext = Class("CompletionContext", {
* @function * @function
*/ */
this.getKey = function getKey(item, key) { this.getKey = function getKey(item, key) {
return (typeof self.keys[key] == "function") ? self.keys[key].call(this, item.item) : if (typeof self.keys[key] == "function")
key in self.keys ? item.item[self.keys[key]] return self.keys[key].call(this, item.item);
: item.item[key];
if (key in self.keys)
return item.item[self.keys[key]];
return item.item[key];
}; };
return this; return this;
}, },
@@ -1318,8 +1322,8 @@ var Completion = Module("completion", {
}, },
setter: function setter(values) { setter: function setter(values) {
if (values.length == 1 && !hasOwnProperty(values[0], this.values) if (values.length == 1 && !hasOwnProp(values[0], this.values)
&& Array.every(values[0], v => hasOwnProperty(this.valueMap, v))) && Array.every(values[0], v => hasOwnProp(this.valueMap, v)))
return Array.map(values[0], v => this.valueMap[v]); return Array.map(values[0], v => this.valueMap[v]);
return values; return values;
+7 -6
View File
@@ -17,6 +17,7 @@ lazyRequire("cache", ["cache"]);
lazyRequire("dom", ["DOM"]); lazyRequire("dom", ["DOM"]);
lazyRequire("highlight", ["highlight"]); lazyRequire("highlight", ["highlight"]);
lazyRequire("messages", ["_"]); lazyRequire("messages", ["_"]);
lazyRequire("overlay", ["overlay"]);
lazyRequire("prefs", ["localPrefs", "prefs"]); lazyRequire("prefs", ["localPrefs", "prefs"]);
lazyRequire("storage", ["storage", "File"]); lazyRequire("storage", ["storage", "File"]);
lazyRequire("styles", ["Styles"]); lazyRequire("styles", ["Styles"]);
@@ -504,7 +505,7 @@ var ConfigBase = Class("ConfigBase", {
oncommand: "toggleSidebar(this.id || this.observes);" }]); oncommand: "toggleSidebar(this.id || this.observes);" }]);
} }
util.overlayWindow(window, { append: append }); overlay.overlayWindow(window, { append: append });
}, },
get window() { return window; }, get window() { return window; },
@@ -632,14 +633,14 @@ config.INIT = update(Object.create(config.INIT), config.INIT, {
let img = new window.Image; let img = new window.Image;
img.src = this.logo || "resource://dactyl-local-content/logo.png"; img.src = this.logo || "resource://dactyl-local-content/logo.png";
img.onload = util.wrapCallback(function () { img.onload = util.wrapCallback(function () {
highlight.loadCSS(literal(function () /* highlight.loadCSS(`
!Logo { !Logo {
display: inline-block; display: inline-block;
background: url({src}); background: url(${img.src});
width: {width}px; width: ${img.width}px;
height: {height}px; height: ${img.height}px;
} }
*/$).replace(/\{(.*?)\}/g, (m, m1) => img[m1])); `);
img = null; img = null;
}); });
}, },
+12 -10
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2010-2014 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2010-2015 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -220,7 +220,7 @@ var Contexts = Module("contexts", {
memoize(contexts.groupsProto, name, function () { memoize(contexts.groupsProto, name, function () {
return [group[name] return [group[name]
for (group of values(this.groups)) for (group of values(this.groups))
if (hasOwnProperty(group, name))]; if (hasOwnProp(group, name))];
}); });
}, },
@@ -242,13 +242,13 @@ var Contexts = Module("contexts", {
let id = util.camelCase(name.replace(/\.[^.]*$/, "")); let id = util.camelCase(name.replace(/\.[^.]*$/, ""));
let contextPath = file.path; let contextPath = file.path;
let self = hasOwnProperty(plugins, contextPath) && plugins.contexts[contextPath]; let self = hasOwnProp(plugins, contextPath) && plugins.contexts[contextPath];
if (!self && isPlugin && false) if (!self && isPlugin && false)
self = hasOwnProperty(plugins, id) && plugins[id]; self = hasOwnProp(plugins, id) && plugins[id];
if (self) { if (self) {
if (hasOwnProperty(self, "onUnload")) if (hasOwnProp(self, "onUnload"))
util.trapErrors("onUnload", self); util.trapErrors("onUnload", self);
} }
else { else {
@@ -340,7 +340,7 @@ var Contexts = Module("contexts", {
.replace(File.PATH_SEP, "-"); .replace(File.PATH_SEP, "-");
let id = util.camelCase(name.replace(/\.[^.]*$/, "")); let id = util.camelCase(name.replace(/\.[^.]*$/, ""));
let self = hasOwnProperty(this.pluginModules, canonical) && this.pluginModules[canonical]; let self = hasOwnProp(this.pluginModules, canonical) && this.pluginModules[canonical];
if (!self) { if (!self) {
self = Object.create(jsmodules); self = Object.create(jsmodules);
@@ -446,7 +446,7 @@ var Contexts = Module("contexts", {
let need = hive ? [hive] let need = hive ? [hive]
: Object.keys(this.hives); : Object.keys(this.hives);
return this.groupList.filter(group => need.some(hasOwnProperty.bind(null, group))); return this.groupList.filter(group => need.some(hasOwnProp.bind(null, group)));
}, },
addGroup: function addGroup(name, description, filter, persist, replace) { addGroup: function addGroup(name, description, filter, persist, replace) {
@@ -506,7 +506,7 @@ var Contexts = Module("contexts", {
getGroup: function getGroup(name, hive) { getGroup: function getGroup(name, hive) {
if (name === "default") if (name === "default")
var group = this.context && this.context.context && this.context.context.GROUP; var group = this.context && this.context.context && this.context.context.GROUP;
else if (hasOwnProperty(this.groupMap, name)) else if (hasOwnProp(this.groupMap, name))
group = this.groupMap[name]; group = this.groupMap[name];
if (group && hive) if (group && hive)
@@ -691,7 +691,7 @@ var Contexts = Module("contexts", {
util.assert(!group.builtin || util.assert(!group.builtin ||
!["-description", "-locations", "-nopersist"] !["-description", "-locations", "-nopersist"]
.some(hasOwnProperty.bind(null, args.explicitOpts)), .some(prop => hasOwnProp(args.explicitOpts, prop)),
_("group.cantModifyBuiltin")); _("group.cantModifyBuiltin"));
}, { }, {
argCount: "?", argCount: "?",
@@ -842,7 +842,9 @@ var Contexts = Module("contexts", {
context.keys = { context.keys = {
active: group => group.filter(uri), active: group => group.filter(uri),
text: "name", text: "name",
description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""] description: g => ["",
g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "",
g.description || ""],
}; };
context.completions = (active === undefined ? contexts.groupList : contexts.initializedGroups(active)) context.completions = (active === undefined ? contexts.groupList : contexts.initializedGroups(active))
.slice(0, -1); .slice(0, -1);
+10 -6
View File
@@ -702,7 +702,7 @@ var DOM = Class("DOM", {
if (callable(v)) if (callable(v))
v = v.call(this, elem, i); v = v.call(this, elem, i);
if (hasOwnProperty(hooks, k) && hooks[k].set) if (hasOwnProp(hooks, k) && hooks[k].set)
hooks[k].set.call(this, elem, v, k); hooks[k].set.call(this, elem, v, k);
else if (v == null) else if (v == null)
elem.removeAttributeNS(ns, k); elem.removeAttributeNS(ns, k);
@@ -714,7 +714,7 @@ var DOM = Class("DOM", {
if (!this.length) if (!this.length)
return null; return null;
if (hasOwnProperty(hooks, key) && hooks[key].get) if (hasOwnProp(hooks, key) && hooks[key].get)
return hooks[key].get.call(this, this[0], key); return hooks[key].get.call(this, this[0], key);
if (!this[0].hasAttributeNS(ns, key)) if (!this[0].hasAttributeNS(ns, key))
@@ -1435,20 +1435,24 @@ var DOM = Class("DOM", {
submit: { cancelable: true } submit: { cancelable: true }
}, },
types: Class.Memoize(() => iter( types: Class.Memoize(() => {
return iter(
{ {
Mouse: "click mousedown mouseout mouseover mouseup dblclick " + Mouse: "click mousedown mouseout mouseover mouseup dblclick " +
"hover " + "hover " +
"popupshowing popupshown popuphiding popuphidden " + "popupshowing popupshown popuphiding popuphidden " +
"contextmenu", "contextmenu",
Key: "keydown keypress keyup", Key: "keydown keypress keyup",
"": "change command dactyl-input input submit " + "": "change command dactyl-input input submit " +
"load unload pageshow pagehide DOMContentLoaded " + "load unload pageshow pagehide DOMContentLoaded " +
"resize scroll" "resize scroll"
} }
).map(([k, v]) => v.split(" ").map(v => [v, k])) ).map(([k, v]) => v.split(" ").map(v => [v, k]))
.flatten() .flatten()
.toObject()), .toObject();
}),
/** /**
* Dispatches an event to an element as if it were a native event. * Dispatches an event to an element as if it were a native event.
@@ -1831,7 +1835,7 @@ var DOM = Class("DOM", {
let res = [indent, "<", name]; let res = [indent, "<", name];
for (let [key, val] of iter(attr)) { for (let [key, val] of iter(attr)) {
if (hasOwnProperty(skipAttr, key)) if (hasOwnProp(skipAttr, key))
continue; continue;
let vals = parseNamespace(key); let vals = parseNamespace(key);
@@ -1984,7 +1988,7 @@ var DOM = Class("DOM", {
Object.keys(DOM.Event.types).forEach(function (event) { Object.keys(DOM.Event.types).forEach(function (event) {
let name = event.replace(/-(.)/g, (m, m1) => m1.toUpperCase()); let name = event.replace(/-(.)/g, (m, m1) => m1.toUpperCase());
if (!hasOwnProperty(DOM.prototype, name)) if (!hasOwnProp(DOM.prototype, name))
DOM.prototype[name] = DOM.prototype[name] =
function _event(arg, extra) { function _event(arg, extra) {
return this[callable(arg) ? "listen" : "dispatch"](event, arg, extra); return this[callable(arg) ? "listen" : "dispatch"](event, arg, extra);
+3 -3
View File
@@ -97,10 +97,10 @@ var Download = Class("Download", {
}), }),
command: function command(name) { command: function command(name) {
util.assert(hasOwnProperty(this.allowedCommands, name), _("download.unknownCommand")); util.assert(hasOwnProp(this.allowedCommands, name), _("download.unknownCommand"));
util.assert(this.allowedCommands[name], _("download.commandNotAllowed")); util.assert(this.allowedCommands[name], _("download.commandNotAllowed"));
if (hasOwnProperty(this.commands, name)) if (hasOwnProp(this.commands, name))
this.commands[name].call(this); this.commands[name].call(this);
}, },
@@ -560,7 +560,7 @@ var Downloads_ = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
validator: function (value) { validator: function (value) {
let seen = new RealSet(); let seen = new RealSet();
return value.every(val => /^[+-]/.test(val) && hasOwnProperty(this.values, val.substr(1)) return value.every(val => /^[+-]/.test(val) && hasOwnProp(this.values, val.substr(1))
&& !seen.add(val.substr(1))) && !seen.add(val.substr(1)))
&& value.length; && value.length;
} }
+6 -6
View File
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2014 Kris Maglione <maglione.k@gmail.com> // Copyright (c) 2008-2015 Kris Maglione <maglione.k@gmail.com>
// //
// This work is licensed for reuse under an MIT license. Details are // This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file. // given in the LICENSE.txt file included with this file.
@@ -111,13 +111,13 @@ var Help = Module("Help", {
{ mimeType: "text/plain;charset=UTF-8" }) { mimeType: "text/plain;charset=UTF-8" })
.responseText; .responseText;
let re = util.regexp(UTF8(literal(function () /* let re = util.regexp(UTF8(String.raw`
^ (?P<comment> \s* # .*\n) ^ (?P<comment> \s* # .*\n)
| ^ (?P<space> \s*) | ^ (?P<space> \s*)
(?P<char> [-*+]) \ // (?P<char> [-*+]) \ //
(?P<content> .*\n (?P<content> .*\n
(?: \2\ \ .*\n | \s*\n)* ) (?: ${"\\2"} // This is incorrectly interpreted as an octal literal otherwise}\ \ .*\n | \s*\n)* )
| (?P<par> | (?P<par>
(?: ^ [^\S\n]* (?: ^ [^\S\n]*
@@ -127,7 +127,7 @@ var Help = Module("Help", {
) )
| (?: ^ [^\S\n]* \n) + | (?: ^ [^\S\n]* \n) +
*/$)), "gmxy"); `), "gmxy");
let betas = util.regexp(/\[((?:b|rc)\d)\]/, "gx"); let betas = util.regexp(/\[((?:b|rc)\d)\]/, "gx");
@@ -241,7 +241,7 @@ var Help = Module("Help", {
* @returns {string} * @returns {string}
*/ */
findHelp: function (topic, consolidated) { findHelp: function (topic, consolidated) {
if (!consolidated && hasOwnProperty(help.files, topic)) if (!consolidated && hasOwnProp(help.files, topic))
return topic; return topic;
let items = modules.completion._runCompleter("help", topic, null, !!consolidated).items; let items = modules.completion._runCompleter("help", topic, null, !!consolidated).items;
let partialMatch = null; let partialMatch = null;
@@ -274,7 +274,7 @@ var Help = Module("Help", {
if (!topic) { if (!topic) {
let helpFile = consolidated ? "all" : modules.options["helpfile"]; let helpFile = consolidated ? "all" : modules.options["helpfile"];
if (hasOwnProperty(help.files, helpFile)) if (hasOwnProp(help.files, helpFile))
dactyl.open("dactyl://help/" + helpFile, { from: "help" }); dactyl.open("dactyl://help/" + helpFile, { from: "help" });
else else
dactyl.echomsg(_("help.noFile", JSON.stringify(helpFile))); dactyl.echomsg(_("help.noFile", JSON.stringify(helpFile)));
+7 -6
View File
@@ -251,14 +251,15 @@ var Highlights = Module("Highlight", {
}); });
}, },
groupRegexp: util.regexp(literal(function () /* groupRegexp: util.regexp(String.raw`
^ ^
(\s* (?:\S|\s\S)+ \s+) (\s* (?:\S|\s\S)+ \s+)
\{ ([^}]*) \} \{ ([^}]*) \}
\s* \s*
$ $
*/$), "gmx"), `, "gmx"),
sheetRegexp: util.regexp(literal(function () /*
sheetRegexp: util.regexp(String.raw`
^\s* ^\s*
!? \*? !? \*?
(?P<group> (?:[^;\s]|\s[^;\s])+ ) (?P<group> (?:[^;\s]|\s[^;\s])+ )
@@ -267,7 +268,7 @@ var Highlights = Module("Highlight", {
(?:; (?P<extends> (?:[^;\s]|\s[^;\s])+ )? )? (?:; (?P<extends> (?:[^;\s]|\s[^;\s])+ )? )?
\s* (?P<css> .*) \s* (?P<css> .*)
$ $
*/$), "x"), `, "x"),
// </css> // </css>
/** /**
@@ -351,7 +352,7 @@ var Highlights = Module("Highlight", {
commands.add(["hi[ghlight]"], commands.add(["hi[ghlight]"],
"Set the style of certain display elements", "Set the style of certain display elements",
function (args) { function (args) {
let style = literal(function () /* let style = `
; ;
display: inline-block !important; display: inline-block !important;
position: static !important; position: static !important;
@@ -359,7 +360,7 @@ var Highlights = Module("Highlight", {
width: 3em !important; min-width: 3em !important; max-width: 3em !important; width: 3em !important; min-width: 3em !important; max-width: 3em !important;
height: 1em !important; min-height: 1em !important; max-height: 1em !important; height: 1em !important; min-height: 1em !important; max-height: 1em !important;
overflow: hidden !important; overflow: hidden !important;
*/$); `;
let clear = args[0] == "clear"; let clear = args[0] == "clear";
if (clear) if (clear)
args.shift(); args.shift();
+47 -28
View File
@@ -313,7 +313,7 @@ var IO = Module("io", {
*/ */
sourcing: null, sourcing: null,
expandPath: deprecated("File.expandPath", function expandPath() apply(File, "expandPath", arguments)), expandPath: deprecated("File.expandPath", function expandPath() { return apply(File, "expandPath", arguments); }),
/** /**
* Returns the first user RC file found in *dir*. * Returns the first user RC file found in *dir*.
@@ -530,15 +530,20 @@ var IO = Module("io", {
stdin.write(input); stdin.write(input);
function result(status, output) { function result(status, output) {
return { return new Proxy(
__noSuchMethod__: function (meth, args) { {
return apply(this.output, meth, args);
},
valueOf: function () { return this.output; }, valueOf: function () { return this.output; },
output: output.replace(/^(.*)\n$/, "$1"), output: output.replace(/^(.*)\n$/, "$1"),
returnValue: status, returnValue: status,
toString: function () { return this.output; } toString: function () { return this.output; },
}; }, {
get(target, prop) {
if (prop in target)
return target[prop];
return target.output[prop];
},
});
} }
function async(status) { function async(status) {
@@ -615,7 +620,7 @@ var IO = Module("io", {
/** /**
* @property {string} The current platform's path separator. * @property {string} The current platform's path separator.
*/ */
PATH_SEP: deprecated("File.PATH_SEP", { get: function PATH_SEP() File.PATH_SEP }) PATH_SEP: deprecated("File.PATH_SEP", { get: function PATH_SEP() { return File.PATH_SEP; } })
}, { }, {
commands: function initCommands(dactyl, modules, window) { commands: function initCommands(dactyl, modules, window) {
const { commands, completion, io } = modules; const { commands, completion, io } = modules;
@@ -723,13 +728,13 @@ var IO = Module("io", {
} }
rtItems.ftdetect.template = //{{{ rtItems.ftdetect.template = //{{{
literal(function () /*" Vim filetype detection file String.raw`" Vim filetype detection file
<header> <header>
au BufNewFile,BufRead *<name>rc*,*.<fileext> set filetype=<name> au BufNewFile,BufRead *<name>rc*,*.<fileext> set filetype=<name>
*/$);//}}} `;//}}}
rtItems.ftplugin.template = //{{{ rtItems.ftplugin.template = //{{{
literal(function () /*" Vim filetype plugin file String.raw`" Vim filetype plugin file
<header> <header>
if exists("b:did_ftplugin") if exists("b:did_ftplugin")
@@ -754,9 +759,9 @@ endif
let &cpo = s:cpo_save let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
*/$);//}}} `; //}}}
rtItems.syntax.template = //{{{ rtItems.syntax.template = //{{{
literal(function () /*" Vim syntax file String.raw`" Vim syntax file
<header> <header>
if exists("b:current_syntax") if exists("b:current_syntax")
@@ -835,7 +840,7 @@ let &cpo = s:cpo_save
unlet s:cpo_save unlet s:cpo_save
" vim: tw=130 et ts=8 sts=4 sw=4: " vim: tw=130 et ts=8 sts=4 sw=4:
*/$);//}}} `;//}}}
const { options } = modules; const { options } = modules;
@@ -1034,12 +1039,26 @@ unlet s:cpo_save
context.title = [full ? "Path" : "Filename", "Type"]; context.title = [full ? "Path" : "Filename", "Type"];
context.keys = { context.keys = {
text: !full ? "leafName" : function (f) this.path, text: !full ? "leafName" : function (f) { return this.path },
path: function (f) dir + f.leafName,
description: function (f) this.isdir ? "Directory" : "File", path(f) {
isdir: function (f) f.isDirectory(), return dir + f.leafName;
icon: function (f) this.isdir ? "resource://gre/res/html/folder.png" },
: "moz-icon://" + f.leafName
description(f) {
return this.isdir ? "Directory" : "File";
},
isdir(f) {
return f.isDirectory();
},
icon(f) {
if (this.isdir)
return "resource://gre/res/html/folder.png";
return "moz-icon://" + f.leafName;
},
}; };
context.compare = (a, b) => b.isdir - a.isdir || String.localeCompare(a.text, b.text); context.compare = (a, b) => b.isdir - a.isdir || String.localeCompare(a.text, b.text);
@@ -1051,20 +1070,20 @@ unlet s:cpo_save
let uri = io.isJarURL(dir); let uri = io.isJarURL(dir);
if (uri) if (uri)
context.generate = function generate_jar() { context.generate = function generate_jar() {
return [ return Array.from(io.listJar(uri.JARFile, getDir(uri.JAREntry)),
{ path => ({
isDirectory: function () s.substr(-1) == "/", isDirectory: () => path.substr(-1) == "/",
leafName: /([^\/]*)\/?$/.exec(s)[1] leafName: /([^\/]*)\/?$/.exec(s)[1]
} }));
for (s of io.listJar(uri.JARFile, getDir(uri.JAREntry)))];
}; };
else else
context.generate = function generate_file() { context.generate = function generate_file() {
try { try {
return io.File(file || dir).readDirectory(); return io.File(file || dir).readDirectory();
} }
catch (e) {} catch (e) {
return []; return [];
}
}; };
}; };
@@ -1098,7 +1117,7 @@ unlet s:cpo_save
}; };
completion.addUrlCompleter("file", "Local files", function (context, full) { completion.addUrlCompleter("file", "Local files", function (context, full) {
let match = util.regexp(literal(function () /* let match = util.regexp(String.raw`
^ ^
(?P<prefix> (?P<prefix>
(?P<proto> (?P<proto>
@@ -1109,7 +1128,7 @@ unlet s:cpo_save
) )
(?P<path> \/[^\/]* )? (?P<path> \/[^\/]* )?
$ $
*/$), "x").exec(context.filter); `, "x").exec(context.filter);
if (match) { if (match) {
if (!match.path) { if (!match.path) {
context.key = match.proto; context.key = match.proto;
+10 -4
View File
@@ -732,6 +732,16 @@ var JavaScript = Module("javascript", {
init: function init(context) { init: function init(context) {
this.context = context; this.context = context;
this.results = []; this.results = [];
return new Proxy(this, {
get(target, prop) {
if (prop in target)
return target[prop];
if (prop in Buffer)
return Buffer[prop].bind(Buffer, target.rootNode);
},
});
}, },
addOutput: function addOutput(js) { addOutput: function addOutput(js) {
@@ -775,10 +785,6 @@ var JavaScript = Module("javascript", {
return this.rootNode; return this.rootNode;
}), }),
__noSuchMethod__: function (meth, args) {
return apply(Buffer, meth, [this.rootNode].concat(args));
}
}); });
modules.CommandREPLMode = Class("CommandREPLMode", modules.CommandMode, { modules.CommandREPLMode = Class("CommandREPLMode", modules.CommandMode, {
+1 -1
View File
@@ -341,7 +341,7 @@ overlay.overlayWindow(Object.keys(config.overlays),
let className = mod.className || mod.constructor.className; let className = mod.className || mod.constructor.className;
if (!hasOwnProperty(init, className)) { if (!hasOwnProp(init, className)) {
init[className] = function callee() { init[className] = function callee() {
function finish() { function finish() {
this.currentDependency = className; this.currentDependency = className;
+1 -1
View File
@@ -160,7 +160,7 @@ var Messages = Module("messages", {
return { configurable: true, enumerable: true, value: this.default, writable: true }; return { configurable: true, enumerable: true, value: this.default, writable: true };
*/ */
if (!hasOwnProperty(obj, "localizedProperties")) if (!hasOwnProp(obj, "localizedProperties"))
obj.localizedProperties = new RealSet(obj.localizedProperties); obj.localizedProperties = new RealSet(obj.localizedProperties);
obj.localizedProperties.add(prop); obj.localizedProperties.add(prop);
+20 -20
View File
@@ -150,7 +150,7 @@ var Option = Class("Option", {
if ((scope & Option.SCOPE_GLOBAL) && (values == undefined)) if ((scope & Option.SCOPE_GLOBAL) && (values == undefined))
values = this.globalValue; values = this.globalValue;
if (hasOwnProperty(this, "_value")) if (hasOwnProp(this, "_value"))
values = this._value; values = this._value;
if (this.getter) if (this.getter)
@@ -354,7 +354,7 @@ var Option = Class("Option", {
let defaultValue = this._defaultValue; let defaultValue = this._defaultValue;
delete this._defaultValue; delete this._defaultValue;
if (hasOwnProperty(this.modules.config.optionDefaults, this.name)) if (hasOwnProp(this.modules.config.optionDefaults, this.name))
defaultValue = this.modules.config.optionDefaults[this.name]; defaultValue = this.modules.config.optionDefaults[this.name];
if (defaultValue == null && this.getter) if (defaultValue == null && this.getter)
@@ -551,7 +551,7 @@ var Option = Class("Option", {
return [Option.quote(k, /:/) + ":" + Option.quote(v, /:/) for ([k, v] of iter(vals))].join(","); return [Option.quote(k, /:/) + ":" + Option.quote(v, /:/) for ([k, v] of iter(vals))].join(",");
}, },
regexplist: function (vals) { return vals.join(","); }, regexplist: vals => vals.join(","),
get regexpmap() { return this.regexplist; }, get regexpmap() { return this.regexplist; },
get sitelist() { return this.regexplist; }, get sitelist() { return this.regexplist; },
get sitemap() { return this.regexplist; } get sitemap() { return this.regexplist; }
@@ -820,8 +820,8 @@ var Option = Class("Option", {
let k = values(completions.call(this, { values: {} })).toObject(); let k = values(completions.call(this, { values: {} })).toObject();
let v = values(completions.call(this, { value: "" })).toObject(); let v = values(completions.call(this, { value: "" })).toObject();
return Object.keys(vals).every(hasOwnProperty.bind(null, k)) && return Object.keys(vals).every(hasOwnProp.bind(null, k)) &&
values(vals).every(hasOwnProperty.bind(null, v)); values(vals).every(hasOwnProp.bind(null, v));
} }
if (this.values) if (this.values)
@@ -894,7 +894,7 @@ var OptionHive = Class("OptionHive", Contexts.Hive, {
init: function init(group) { init: function init(group) {
init.supercall(this, group); init.supercall(this, group);
this.values = {}; this.values = {};
this.has = v => hasOwnProperty(this.values, v); this.has = v => hasOwnProp(this.values, v);
}, },
add: function add(names, description, type, defaultValue, extra) { add: function add(names, description, type, defaultValue, extra) {
@@ -1067,18 +1067,18 @@ var Options = Module("options", {
return values(this._options.sort((a, b) => String.localeCompare(a.name, b.name))); return values(this._options.sort((a, b) => String.localeCompare(a.name, b.name)));
}, },
allPrefs: deprecated("prefs.getNames", function allPrefs() apply(prefs, "getNames", arguments)), allPrefs: deprecated("prefs.getNames", function allPrefs() { return apply(prefs, "getNames", arguments); }),
getPref: deprecated("prefs.get", function getPref() apply(prefs, "get", arguments)), getPref: deprecated("prefs.get", function getPref() { return apply(prefs, "get", arguments); }),
invertPref: deprecated("prefs.invert", function invertPref() apply(prefs, "invert", arguments)), invertPref: deprecated("prefs.invert", function invertPref() { return apply(prefs, "invert", arguments); }),
listPrefs: deprecated("prefs.list", function listPrefs() { this.modules.commandline.commandOutput(apply(prefs, "list", arguments)); }), listPrefs: deprecated("prefs.list", function listPrefs() { this.modules.commandline.commandOutput(apply(prefs, "list", arguments)); }),
observePref: deprecated("prefs.observe", function observePref() apply(prefs, "observe", arguments)), observePref: deprecated("prefs.observe", function observePref() { return apply(prefs, "observe", arguments); }),
popContext: deprecated("prefs.popContext", function popContext() apply(prefs, "popContext", arguments)), popContext: deprecated("prefs.popContext", function popContext() { return apply(prefs, "popContext", arguments); }),
pushContext: deprecated("prefs.pushContext", function pushContext() apply(prefs, "pushContext", arguments)), pushContext: deprecated("prefs.pushContext", function pushContext() { return apply(prefs, "pushContext", arguments); }),
resetPref: deprecated("prefs.reset", function resetPref() apply(prefs, "reset", arguments)), resetPref: deprecated("prefs.reset", function resetPref() { return apply(prefs, "reset", arguments); }),
safeResetPref: deprecated("prefs.safeReset", function safeResetPref() apply(prefs, "safeReset", arguments)), safeResetPref: deprecated("prefs.safeReset", function safeResetPref() { return apply(prefs, "safeReset", arguments); }),
safeSetPref: deprecated("prefs.safeSet", function safeSetPref() apply(prefs, "safeSet", arguments)), safeSetPref: deprecated("prefs.safeSet", function safeSetPref() { return apply(prefs, "safeSet", arguments); }),
setPref: deprecated("prefs.set", function setPref() apply(prefs, "set", arguments)), setPref: deprecated("prefs.set", function setPref() { return apply(prefs, "set", arguments); }),
withContext: deprecated("prefs.withContext", function withContext() apply(prefs, "withContext", arguments)), withContext: deprecated("prefs.withContext", function withContext() { return apply(prefs, "withContext", arguments); }),
cleanupPrefs: Class.Memoize(() => config.prefs.Branch("cleanup.option.")), cleanupPrefs: Class.Memoize(() => config.prefs.Branch("cleanup.option.")),
@@ -1431,7 +1431,7 @@ var Options = Module("options", {
util.assert(scope == "g:" || scope == null, util.assert(scope == "g:" || scope == null,
_("command.let.illegalVar", scope + name)); _("command.let.illegalVar", scope + name));
util.assert(hasOwnProperty(globalVariables, name) || (expr && !op), util.assert(hasOwnProp(globalVariables, name) || (expr && !op),
_("command.let.undefinedVar", fullName)); _("command.let.undefinedVar", fullName));
if (!expr) if (!expr)
@@ -1535,7 +1535,7 @@ var Options = Module("options", {
function (args) { function (args) {
for (let name of args) { for (let name of args) {
name = name.replace(/^g:/, ""); // throw away the scope prefix name = name.replace(/^g:/, ""); // throw away the scope prefix
if (!hasOwnProperty(dactyl._globalVariables, name)) { if (!hasOwnProp(dactyl._globalVariables, name)) {
if (!args.bang) if (!args.bang)
dactyl.echoerr(_("command.let.noSuch", name)); dactyl.echoerr(_("command.let.noSuch", name));
return; return;
@@ -1620,7 +1620,7 @@ var Options = Module("options", {
let val = [].find.call(obj, re => (re.key == extra.key)); let val = [].find.call(obj, re => (re.key == extra.key));
return val && val.result; return val && val.result;
} }
if (hasOwnProperty(opt.defaultValue, extra.key)) if (hasOwnProp(opt.defaultValue, extra.key))
return obj[extra.key]; return obj[extra.key];
} }
+6 -1
View File
@@ -489,7 +489,12 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
return this.windows.has(win) && win; return this.windows.has(win) && win;
}, },
set activeWindow(win) { this._activeWindow = util.weakReference(win); }, set activeWindow(win) {
this._activeWindow = util.weakReference(win);
if (win.dactyl)
util.flushLateMethods(win.dactyl);
},
/** /**
* A list of extant dactyl windows. * A list of extant dactyl windows.
+2 -1
View File
@@ -134,7 +134,8 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
} }
}, },
getDefault: deprecated("Prefs#defaults.get", function getDefault(name, defaultValue) this.defaults.get(name, defaultValue)), getDefault: deprecated("Prefs#defaults.get",
function getDefault(name, defaultValue) { return this.defaults.get(name, defaultValue); }),
/** /**
* Returns an array of all preference names in this branch or the * Returns an array of all preference names in this branch or the
+7 -3
View File
@@ -86,6 +86,8 @@ function ProtocolBase() {
this.pages = {}; this.pages = {};
this.providers = { this.providers = {
__proto__: null,
"content": function (uri, path) { "content": function (uri, path) {
return this.pages[path] || this.contentBase + path; return this.pages[path] || this.contentBase + path;
}, },
@@ -98,7 +100,7 @@ function ProtocolBase() {
channel.owner = systemPrincipal; channel.owner = systemPrincipal;
channel.originalURI = uri; channel.originalURI = uri;
return channel; return channel;
} },
}; };
} }
ProtocolBase.prototype = { ProtocolBase.prototype = {
@@ -196,7 +198,7 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) {
let type = this.channel.contentType; let type = this.channel.contentType;
if (/^text\/|[\/+]xml$/.test(type)) { if (/^text\/|[\/+]xml$/.test(type)) {
let stream = services.InputStream(channelStream); let stream = services.InputStream(channelStream);
let [, pre, doctype, url, extra, open, post] = util.regexp(literal(function () /* let [, pre, doctype, url, extra, open, post] = util.regexp(String.raw`
^ ([^]*?) ^ ([^]*?)
(?: (?:
(<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*)) (<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*))
@@ -204,8 +206,10 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) {
([^]*) ([^]*)
)? )?
$ $
*/$), "x").exec(stream.read(4096)); `, "x").exec(stream.read(4096));
this.writes.push(pre); this.writes.push(pre);
if (doctype) { if (doctype) {
this.writes.push(doctype + (extra || "") + " [\n"); this.writes.push(doctype + (extra || "") + " [\n");
if (url) if (url)
+8 -3
View File
@@ -28,8 +28,13 @@ tmp.Sanitizer.prototype.__proto__ = Class.prototype;
var Range = Struct("min", "max"); var Range = Struct("min", "max");
update(Range.prototype, { update(Range.prototype, {
contains: function (date) date == null || contains: function (date) {
(this.min == null || date >= this.min) && (this.max == null || date <= this.max), if (date != null)
return ((this.min == null || date >= this.min) &&
(this.max == null || date <= this.max));
return false;
},
get isEternity() { get isEternity() {
return this.max == null && this.min == null; return this.max == null && this.min == null;
@@ -662,7 +667,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
validator: function (values) { validator: function (values) {
return values.length && return values.length &&
values.every(val => (val === "all" || hasOwnProperty(sanitizer.itemMap, val.replace(/^!/, "")))); values.every(val => (val === "all" || hasOwnProp(sanitizer.itemMap, val.replace(/^!/, ""))));
} }
}); });
+3 -3
View File
@@ -194,14 +194,14 @@ var Services = Module("Services", {
* *
* @param {string} name The class's cache key. * @param {string} name The class's cache key.
*/ */
create: deprecated("services.*name*()", function create(name) this[util.capitalize(name)]()), create: deprecated("services.*name*()", function create(name) { return this[util.capitalize(name)](); }),
/** /**
* Returns the cached service with the specified name. * Returns the cached service with the specified name.
* *
* @param {string} name The service's cache key. * @param {string} name The service's cache key.
*/ */
get: deprecated("services.*name*", function get(name) this[name]), get: deprecated("services.*name*", function get(name) { return this[name]; }),
/** /**
* Returns true if the given service is available. * Returns true if the given service is available.
@@ -209,7 +209,7 @@ var Services = Module("Services", {
* @param {string} name The service's cache key. * @param {string} name The service's cache key.
*/ */
has: function has(name) { has: function has(name) {
return hasOwnProperty(this.services, name) && return hasOwnProp(this.services, name) &&
this.services[name].class in Cc && this.services[name].class in Cc &&
this.services[name].interfaces.every(iface => iface in Ci); this.services[name].interfaces.every(iface => iface in Ci);
} }
+18 -12
View File
@@ -70,7 +70,7 @@ var StoreBase = Class("StoreBase", {
save: function () { (this.storage || storage)._saveData(this); }, save: function () { (this.storage || storage)._saveData(this); },
"@@iterator": function () iter(this._object) "@@iterator": function () { return iter(this._object); },
}); });
var ArrayStore = Class("ArrayStore", StoreBase, { var ArrayStore = Class("ArrayStore", StoreBase, {
@@ -160,7 +160,7 @@ var ObjectStore = Class("ObjectStore", StoreBase, {
}, },
has: function has(key) { has: function has(key) {
return hasOwnProperty(this._object, key); return hasOwnProp(this._object, key);
}, },
keys: function keys() { keys: function keys() {
@@ -257,11 +257,14 @@ var Storage = Module("Storage", {
delete this.dactylSession[key]; delete this.dactylSession[key];
}, },
infoPath: Class.Memoize(() => infoPath: Class.Memoize(function () {
File(IO.runtimePath.split(",")[0]) return File(IO.runtimePath.split(",")[0])
.child("info").child(config.profileName)), .child("info").child(config.profileName);
}),
exists: function exists(key) this.infoPath.child(key).exists(), exists: function exists(key) {
return this.infoPath.child(key).exists();
},
remove: function remove(key) { remove: function remove(key) {
if (this.exists(key)) { if (this.exists(key)) {
@@ -327,7 +330,7 @@ var Storage = Module("Storage", {
if (window instanceof Ci.nsIDOMWindow) if (window instanceof Ci.nsIDOMWindow)
observers = overlay.getData(window, "storage-observers", Object); observers = overlay.getData(window, "storage-observers", Object);
if (!hasOwnProperty(observers, key)) if (!hasOwnProp(observers, key))
observers[key] = new RealSet; observers[key] = new RealSet;
observers[key].add(callback); observers[key].add(callback);
@@ -559,7 +562,7 @@ var File = Class("File", {
* *
* @returns {nsIFileURL} * @returns {nsIFileURL}
*/ */
toURI: deprecated("#URI", function toURI() services.io.newFileURI(this.file)), toURI: deprecated("#URI", function toURI() { return services.io.newFileURI(this.file); }),
/** /**
* Writes the string *buf* to this file. * Writes the string *buf* to this file.
@@ -724,14 +727,17 @@ var File = Class("File", {
}), }),
DoesNotExist: function DoesNotExist(path, error) { DoesNotExist: function DoesNotExist(path, error) {
return { return new Proxy({
__proto__: DoesNotExist.prototype, __proto__: DoesNotExist.prototype,
path: path, path: path,
exists: function () { return false; }, exists: function () { return false; },
__noSuchMethod__: function () { }, {
throw error || Error("Does not exist"); get(target, prop) {
if (prop in target)
return target[prop];
return () => { error || Error("Does not exist")};
} }
}; });
}, },
defaultEncoding: "UTF-8", defaultEncoding: "UTF-8",
+31 -25
View File
@@ -274,7 +274,7 @@ var Styles = Module("Styles", {
update(services["dactyl:"].providers, { update(services["dactyl:"].providers, {
"style": function styleProvider(uri, path) { "style": function styleProvider(uri, path) {
let id = parseInt(path); let id = parseInt(path);
if (hasOwnProperty(styles.allSheets, id)) if (hasOwnProp(styles.allSheets, id))
return ["text/css", styles.allSheets[id].fullCSS]; return ["text/css", styles.allSheets[id].fullCSS];
return null; return null;
} }
@@ -311,16 +311,16 @@ var Styles = Module("Styles", {
return apply(obj, name, Array.slice(args, 1)); return apply(obj, name, Array.slice(args, 1));
}, },
addSheet: deprecated("Styles#{user,system}.add", function addSheet() this._proxy("add", arguments)), addSheet: deprecated("Styles#{user,system}.add", function addSheet() { return this._proxy("add", arguments); }),
findSheets: deprecated("Styles#{user,system}.find", function findSheets() this._proxy("find", arguments)), findSheets: deprecated("Styles#{user,system}.find", function findSheets() { return this._proxy("find", arguments); }),
get: deprecated("Styles#{user,system}.get", function get() this._proxy("get", arguments)), get: deprecated("Styles#{user,system}.get", function get() { return this._proxy("get", arguments); }),
removeSheet: deprecated("Styles#{user,system}.remove", function removeSheet() this._proxy("remove", arguments)), removeSheet: deprecated("Styles#{user,system}.remove", function removeSheet() { return this._proxy("remove", arguments); }),
userSheets: Class.Property({ get: deprecated("Styles#user.sheets", function userSheets() this.user.sheets) }), userSheets: Class.Property({ get: deprecated("Styles#user.sheets", function userSheets() { return this.user.sheets; }) }),
systemSheets: Class.Property({ get: deprecated("Styles#system.sheets", function systemSheets() this.system.sheets) }), systemSheets: Class.Property({ get: deprecated("Styles#system.sheets", function systemSheets() { return this.system.sheets; }) }),
userNames: Class.Property({ get: deprecated("Styles#user.names", function userNames() this.user.names) }), userNames: Class.Property({ get: deprecated("Styles#user.names", function userNames() { return this.user.names; }) }),
systemNames: Class.Property({ get: deprecated("Styles#system.names", function systemNames() this.system.names) }), systemNames: Class.Property({ get: deprecated("Styles#system.names", function systemNames() { return this.system.names; }) }),
sites: Class.Property({ get: deprecated("Styles#user.sites", function sites() this.user.sites) }), sites: Class.Property({ get: deprecated("Styles#user.sites", function sites() { return this.user.sites; }) }),
list: function list(content, sites, name, hives) { list: function list(content, sites, name, hives) {
const { commandline, dactyl } = this.modules; const { commandline, dactyl } = this.modules;
@@ -376,8 +376,9 @@ var Styles = Module("Styles", {
this.unregisterSheet(url, agent); this.unregisterSheet(url, agent);
let type = services.stylesheet[agent ? "AGENT_SHEET" : "USER_SHEET"]; let type = services.stylesheet[agent ? "AGENT_SHEET" : "USER_SHEET"];
if (reload || !services.stylesheet.sheetRegistered(uri, type)) if (reload || !services.stylesheet.sheetRegistered(uri, type)) {
services.stylesheet.loadAndRegisterSheet(uri, type); services.stylesheet.loadAndRegisterSheet(uri, type);
}
}, },
unregisterSheet: function unregisterSheet(url, agent) { unregisterSheet: function unregisterSheet(url, agent) {
@@ -493,7 +494,7 @@ var Styles = Module("Styles", {
} }
}, },
propertyPattern: util.regexp(literal(function () /* propertyPattern: util.regexp(String.raw`
(?: (?:
(?P<preSpace> <space>*) (?P<preSpace> <space>*)
(?P<name> [-a-z]*) (?P<name> [-a-z]*)
@@ -515,7 +516,7 @@ var Styles = Module("Styles", {
)? )?
) )
(?P<postSpace> <space>* (?: ; | $) ) (?P<postSpace> <space>* (?: ; | $) )
*/$), "gix", `, "gix",
{ {
space: /(?: \s | \/\* .*? \*\/ )/, space: /(?: \s | \/\* .*? \*\/ )/,
string: /(?:" (?:[^\\"]|\\.)* (?:"|$) | '(?:[^\\']|\\.)* (?:'|$) )/ string: /(?:" (?:[^\\"]|\\.)* (?:"|$) | '(?:[^\\']|\\.)* (?:'|$) )/
@@ -523,7 +524,7 @@ var Styles = Module("Styles", {
patterns: memoize({ patterns: memoize({
get property() { get property() {
return util.regexp(literal(function () /* return util.regexp(String.raw`
(?: (?:
(?P<preSpace> <space>*) (?P<preSpace> <space>*)
(?P<name> [-a-z]*) (?P<name> [-a-z]*)
@@ -534,32 +535,32 @@ var Styles = Module("Styles", {
)? )?
) )
(?P<postSpace> <space>* (?: ; | $) ) (?P<postSpace> <space>* (?: ; | $) )
*/$), "gix", this); `, "gix", this);
}, },
get function() { get function() {
return util.regexp(literal(function () /* return util.regexp(String.raw`
(?P<function> (?P<function>
\s* \( \s* \s* \( \s*
(?: <string> | [^)]* ) (?: <string> | [^)]* )
\s* (?: \) | $) \s* (?: \) | $)
) )
*/$), "gx", this); `, "gx", this);
}, },
space: /(?: \s | \/\* .*? \*\/ )/, space: /(?: \s | \/\* .*? \*\/ )/,
get string() { get string() {
return util.regexp(literal(function () /* return util.regexp(String.raw`
(?P<string> (?P<string>
" (?:[^\\"]|\\.)* (?:"|$) | " (?:[^\\"]|\\.)* (?:"|$) |
' (?:[^\\']|\\.)* (?:'|$) ' (?:[^\\']|\\.)* (?:'|$)
) )
*/$), "gx", this); `, "gx", this);
}, },
get token() { get token() {
return util.regexp(literal(function () /* return util.regexp(String.raw`
(?P<token> (?P<token>
(?P<word> [-\w]+) (?P<word> [-\w]+)
<function>? <function>?
@@ -569,7 +570,7 @@ var Styles = Module("Styles", {
| <space>+ | <space>+
| [^;}\s]+ | [^;}\s]+
) )
*/$), "gix", this); `, "gix", this);
} }
}), }),
@@ -744,16 +745,21 @@ var Styles = Module("Styles", {
init: function init(group) { init: function init(group) {
init.superapply(this, arguments); init.superapply(this, arguments);
this.hive = styles.addHive(group.name, this, this.persist); this.hive = styles.addHive(group.name, this, this.persist);
return new Proxy(this, {
get(target, prop) {
if (prop in target)
return target[prop];
return target.hive[prop];
},
});
}, },
get names() { return this.hive.names; }, get names() { return this.hive.names; },
get sheets() { return this.hive.sheets; }, get sheets() { return this.hive.sheets; },
get sites() { return this.hive.sites; }, get sites() { return this.hive.sites; },
__noSuchMethod__: function __noSuchMethod__(meth, args) {
return apply(this.hive, meth, args);
},
destroy: function () { destroy: function () {
this.hive.dropRef(this); this.hive.dropRef(this);
} }
+33 -17
View File
@@ -16,12 +16,28 @@ var Binding = Class("Binding", {
init: function (node, nodes) { init: function (node, nodes) {
this.node = node; this.node = node;
this.nodes = nodes; this.nodes = nodes;
node.dactylBinding = this;
Object.defineProperties(node, this.constructor.properties); Object.defineProperties(node, this.constructor.properties);
for (let [event, handler] of this.constructor.events) for (let [event, handler] of this.constructor.events)
node.addEventListener(event, util.wrapCallback(handler, true), false); node.addEventListener(event, util.wrapCallback(handler, true), false);
let proxy = new Proxy(this, {
get(target, prop) {
if (prop in target)
return target[prop];
let { node } = target;
let value = node[prop];
if (callable(value))
return value.bind(node);
return value;
},
});
node.dactylBinding = proxy;
return proxy;
}, },
set collapsed(collapsed) { set collapsed(collapsed) {
@@ -30,20 +46,16 @@ var Binding = Class("Binding", {
else else
this.removeAttribute("collapsed"); this.removeAttribute("collapsed");
}, },
get collapsed() { return !!this.getAttribute("collapsed"); },
__noSuchMethod__: Class.Property({ get collapsed() { return !!this.getAttribute("collapsed"); },
configurable: true,
writeable: true,
value: function __noSuchMethod__(meth, args) {
return apply(this.node, meth, args);
}
})
}, { }, {
get bindings() { get bindings() {
return function* () { return function* () {
let bindingProto = Object.getPrototypeOf(Binding.prototype); let bindingProto = Object.getPrototypeOf(Binding.prototype);
for (let obj = this.prototype; obj !== bindingProto; obj = Object.getPrototypeOf(obj))
for (let obj = this.prototype;
obj !== bindingProto;
obj = Object.getPrototypeOf(obj))
/* FIXME: Symbols */ /* FIXME: Symbols */
yield obj; yield obj;
}.call(this); }.call(this);
@@ -63,15 +75,18 @@ var Binding = Class("Binding", {
events: Class.Memoize(function () { events: Class.Memoize(function () {
let res = []; let res = [];
for (let obj of this.bindings) for (let obj of this.bindings)
if (Object.getOwnPropertyDescriptor(obj, "events")) if (Object.getOwnPropertyDescriptor(obj, "events"))
for (let [event, handler] of iter(obj.events)) for (let [event, handler] of iter(obj.events))
res.push([event, this.bind(handler)]); res.push([event, this.bind(handler)]);
return res; return res;
}), }),
properties: Class.Memoize(function () { properties: Class.Memoize(function () {
let res = {}; let res = {};
for (let obj of this.bindings) for (let obj of this.bindings)
for (let prop of properties(obj)) { for (let prop of properties(obj)) {
let desc = Object.getOwnPropertyDescriptor(obj, prop); let desc = Object.getOwnPropertyDescriptor(obj, prop);
@@ -82,6 +97,7 @@ var Binding = Class("Binding", {
res[prop] = desc; res[prop] = desc;
} }
} }
return res; return res;
}) })
}); });
@@ -114,7 +130,7 @@ var Template = Module("Template", {
"click": function onClick(event) { "click": function onClick(event) {
event.preventDefault(); event.preventDefault();
if (this.commandAllowed) { if (this.commandAllowed) {
if (hasOwnProperty(this.target.commands || {}, this.command)) if (hasOwnProp(this.target.commands || {}, this.command))
this.target.commands[this.command].call(this.target); this.target.commands[this.command].call(this.target);
else else
this.target.command(this.command); this.target.command(this.command);
@@ -123,7 +139,7 @@ var Template = Module("Template", {
}, },
get commandAllowed() { get commandAllowed() {
if (hasOwnProperty(this.target.allowedCommands || {}, this.command)) if (hasOwnProp(this.target.allowedCommands || {}, this.command))
return this.target.allowedCommands[this.command]; return this.target.allowedCommands[this.command];
if ("commandAllowed" in this.target) if ("commandAllowed" in this.target)
return this.target.commandAllowed(this.command); return this.target.commandAllowed(this.command);
@@ -148,7 +164,7 @@ var Template = Module("Template", {
let obj = params.eventTarget; let obj = params.eventTarget;
let events = obj[this.getAttribute("events") || "events"]; let events = obj[this.getAttribute("events") || "events"];
if (hasOwnProperty(events, "input")) if (hasOwnProp(events, "input"))
events["dactyl-input"] = events["input"]; events["dactyl-input"] = events["input"];
for (let [event, handler] of iter(events)) for (let [event, handler] of iter(events))
@@ -231,7 +247,7 @@ var Template = Module("Template", {
else if (/^n_/.test(topic)) else if (/^n_/.test(topic))
topic = topic.slice(2); topic = topic.slice(2);
if (help.initialized && !hasOwnProperty(help.tags, topic)) if (help.initialized && !hasOwnProp(help.tags, topic))
return ["span", { highlight: type || ""}, text || token]; return ["span", { highlight: type || ""}, text || token];
type = type || (/^'.*'$/.test(token) ? "HelpOpt" : type = type || (/^'.*'$/.test(token) ? "HelpOpt" :
@@ -253,7 +269,7 @@ var Template = Module("Template", {
else if (/^n_/.test(topic)) else if (/^n_/.test(topic))
topic = topic.slice(2); topic = topic.slice(2);
if (help.initialized && !hasOwnProperty(help.tags, topic)) if (help.initialized && !hasOwnProp(help.tags, topic))
return token; return token;
let tag = (/^'.*'$/.test(token) ? "o" : let tag = (/^'.*'$/.test(token) ? "o" :
@@ -264,11 +280,11 @@ var Template = Module("Template", {
return [tag, { xmlns: "dactyl" }, topic]; return [tag, { xmlns: "dactyl" }, topic];
}, },
linkifyHelp: function linkifyHelp(str, help) { linkifyHelp: function linkifyHelp(str, help) {
let re = util.regexp(literal(function () /* let re = util.regexp(String.raw`
(?P<pre> [/\s]|^) (?P<pre> [/\s]|^)
(?P<tag> '[\w-]+' | :(?:[\w-]+!?|!) | (?:._)?<[\w-]+>\w* | \b[a-zA-Z]_(?:[\w[\]]+|.) | \[[\w-;]+\] | E\d{3} ) (?P<tag> '[\w-]+' | :(?:[\w-]+!?|!) | (?:._)?<[\w-]+>\w* | \b[a-zA-Z]_(?:[\w[\]]+|.) | \[[\w-;]+\] | E\d{3} )
(?= [[\)!,:;./\s]|$) (?= [[\)!,:;./\s]|$)
*/$), "gx"); `, "gx");
return this.highlightSubstrings(str, (function* () { return this.highlightSubstrings(str, (function* () {
for (let res of re.iterate(str)) for (let res of re.iterate(str))
yield [res.index + res.pre.length, res.tag.length]; yield [res.index + res.pre.length, res.tag.length];
+85 -62
View File
@@ -61,6 +61,17 @@ var wrapCallback = function wrapCallback(fn, isEvent) {
return fn.wrapper; return fn.wrapper;
}; };
let anythingObjectHack = new Proxy({}, {
get(target, prop) {
util.dump("Attempt to access UI method before UI ready: " + prop);
return function(...args) {
util.dump(`Attempt to use UI method before UI ready: ${prop}(${args})`);
util.lateDactylMethods.push([prop, args]);
};
},
});
var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), { var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
Magic: Magic, Magic: Magic,
@@ -69,61 +80,68 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
this.addObserver(this); this.addObserver(this);
this.windows = []; this.windows = [];
this.lateDactylMethods = [];
}, },
activeWindow: deprecated("overlay.activeWindow", { get: function activeWindow() overlay.activeWindow }), activeWindow: deprecated("overlay.activeWindow", { get: function activeWindow() { return overlay.activeWindow; } }),
overlayObject: deprecated("overlay.overlayObject", { get: function overlayObject() overlay.bound.overlayObject }), overlayObject: deprecated("overlay.overlayObject", { get: function overlayObject() { return overlay.bound.overlayObject; } }),
overlayWindow: deprecated("overlay.overlayWindow", { get: function overlayWindow() overlay.bound.overlayWindow }), overlayWindow: deprecated("overlay.overlayWindow", { get: function overlayWindow() { return overlay.bound.overlayWindow; } }),
compileMatcher: deprecated("DOM.compileMatcher", { get: function compileMatcher() { return DOM.compileMatcher; } }),
computedStyle: deprecated("DOM#style", function computedStyle(elem) { return DOM(elem).style; }),
domToString: deprecated("DOM.stringify", { get: function domToString() { return DOM.stringify; } }),
editableInputs: deprecated("DOM.editableInputs", { get: function editableInputs(elem) { return DOM.editableInputs; } }),
escapeHTML: deprecated("DOM.escapeHTML", { get: function escapeHTML(elem) { return DOM.escapeHTML; } }),
compileMatcher: deprecated("DOM.compileMatcher", { get: function compileMatcher() DOM.compileMatcher }),
computedStyle: deprecated("DOM#style", function computedStyle(elem) DOM(elem).style),
domToString: deprecated("DOM.stringify", { get: function domToString() DOM.stringify }),
editableInputs: deprecated("DOM.editableInputs", { get: function editableInputs(elem) DOM.editableInputs }),
escapeHTML: deprecated("DOM.escapeHTML", { get: function escapeHTML(elem) DOM.escapeHTML }),
evaluateXPath: deprecated("DOM.XPath", evaluateXPath: deprecated("DOM.XPath",
function evaluateXPath(path, elem, asIterator) DOM.XPath(path, elem || util.activeWindow.content.document, asIterator)), function evaluateXPath(path, elem, asIterator) {
isVisible: deprecated("DOM#isVisible", function isVisible(elem) DOM(elem).isVisible), return DOM.XPath(path, elem || util.activeWindow.content.document, asIterator);
makeXPath: deprecated("DOM.makeXPath", { get: function makeXPath(elem) DOM.makeXPath }),
namespaces: deprecated("DOM.namespaces", { get: function namespaces(elem) DOM.namespaces }),
namespaceNames: deprecated("DOM.namespaceNames", { get: function namespaceNames(elem) DOM.namespaceNames }),
parseForm: deprecated("DOM#formData", function parseForm(elem) values(DOM(elem).formData).toArray()),
scrollIntoView: deprecated("DOM#scrollIntoView", function scrollIntoView(elem, alignWithTop) DOM(elem).scrollIntoView(alignWithTop)),
validateMatcher: deprecated("DOM.validateMatcher", { get: function validateMatcher() DOM.validateMatcher }),
map: deprecated("iter.map", function map(obj, fn, self) iter(obj).map(fn, self).toArray()),
writeToClipboard: deprecated("dactyl.clipboardWrite", function writeToClipboard(str, verbose) util.dactyl.clipboardWrite(str, verbose)),
readFromClipboard: deprecated("dactyl.clipboardRead", function readFromClipboard() util.dactyl.clipboardRead(false)),
chromePackages: deprecated("config.chromePackages", { get: function chromePackages() config.chromePackages }),
haveGecko: deprecated("config.haveGecko", { get: function haveGecko() config.bound.haveGecko }),
OS: deprecated("config.OS", { get: function OS() config.OS }),
identity: deprecated("identity", { get: function identity() global.identity }),
dactyl: update(function dactyl(obj) {
if (obj)
var global = Class.objectGlobal(obj);
return {
__noSuchMethod__: function __noSuchMethod__(meth, args) {
let win = overlay.activeWindow;
var dactyl = global && global.dactyl || win && win.dactyl;
if (!dactyl)
return null;
let prop = dactyl[meth];
if (callable(prop))
return prop.apply(dactyl, args);
return prop;
}
};
}, {
__noSuchMethod__: function __noSuchMethod__() {
return this().__noSuchMethod__.apply(null, arguments);
}
}), }),
isVisible: deprecated("DOM#isVisible", function isVisible(elem) { return DOM(elem).isVisible; }),
makeXPath: deprecated("DOM.makeXPath", { get: function makeXPath(elem) { return DOM.makeXPath; } }),
namespaces: deprecated("DOM.namespaces", { get: function namespaces(elem) { return DOM.namespaces; } }),
namespaceNames: deprecated("DOM.namespaceNames", { get: function namespaceNames(elem) { return DOM.namespaceNames; } }),
parseForm: deprecated("DOM#formData", function parseForm(elem) { return values(DOM(elem).formData).toArray(); }),
scrollIntoView: deprecated("DOM#scrollIntoView", function scrollIntoView(elem, alignWithTop) { return DOM(elem).scrollIntoView(alignWithTop); }),
validateMatcher: deprecated("DOM.validateMatcher", { get: function validateMatcher() { return DOM.validateMatcher; } }),
map: deprecated("iter.map", function map(obj, fn, self) { return iter(obj).map(fn, self).toArray(); }),
writeToClipboard: deprecated("dactyl.clipboardWrite", function writeToClipboard(str, verbose) { return util.dactyl.clipboardWrite(str, verbose); }),
readFromClipboard: deprecated("dactyl.clipboardRead", function readFromClipboard() { return util.dactyl.clipboardRead(false); }),
chromePackages: deprecated("config.chromePackages", { get: function chromePackages() { return config.chromePackages; } }),
haveGecko: deprecated("config.haveGecko", { get: function haveGecko() { return config.bound.haveGecko; } }),
OS: deprecated("config.OS", { get: function OS() { return config.OS; } }),
identity: deprecated("identity", { get: function identity() { return global.identity; } }),
dactyl: new Proxy(function (obj) {
let global;
if (obj)
global = Class.objectGlobal(obj);
return (global && global.dactyl ||
overlay.activeWindow && overlay.activeWindow.dactyl ||
anythingObjectHack);
}, {
get(target, prop) {
if (prop in target)
return target[prop];
if (loaded.overlay)
return target()[prop];
},
}),
flushLateMethods(dactyl) {
while (this.lateDactylMethods.length) {
let [meth, args] = this.lateDactylMethods.shift();
this.trapErrors(meth, dactyl, ...args);
}
},
/** /**
* Registers a obj as a new observer with the observer service. obj.observe * Registers a obj as a new observer with the observer service. obj.observe
* must be an object where each key is the name of a target to observe and * must be an object where each key is the name of a target to observe and
@@ -379,14 +397,15 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
let defaults = { lt: "<", gt: ">" }; let defaults = { lt: "<", gt: ">" };
let re = util.regexp(literal(function () /* let re = util.regexp(String.raw`
([^]*?) // 1 ([^]*?) // 1
(?: (?:
(<\{) | // 2 (<\{) | // 2
(< ((?:[a-z]-)?[a-z-]+?) (?:\[([0-9]+)\])? >) | // 3 4 5 (< ((?:[a-z]-)?[a-z-]+?) (?:\[([0-9]+)\])? >) | // 3 4 5
(\}>) // 6 (\}>) // 6
) )
*/$), "gixy"); `, "gixy");
macro = String(macro); macro = String(macro);
let end = 0; let end = 0;
for (let match of re.iterate(macro)) { for (let match of re.iterate(macro)) {
@@ -416,7 +435,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (flags.has("e")) if (flags.has("e"))
quote = function quote(obj) { return ""; }; quote = function quote(obj) { return ""; };
if (hasOwnProperty(defaults, name)) if (hasOwnProp(defaults, name))
stack.top.elements.push(quote(defaults[name])); stack.top.elements.push(quote(defaults[name]));
else { else {
let index = idx; let index = idx;
@@ -424,7 +443,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
idx = Number(idx) - 1; idx = Number(idx) - 1;
stack.top.elements.push(update( stack.top.elements.push(update(
obj => obj[name] != null && idx in obj[name] ? quote(obj[name][idx]) obj => obj[name] != null && idx in obj[name] ? quote(obj[name][idx])
: hasOwnProperty(obj, name) ? "" : unknown(full), : hasOwnProp(obj, name) ? "" : unknown(full),
{ {
test: function test(obj) { test: function test(obj) {
return obj[name] != null && return obj[name] != null &&
@@ -437,7 +456,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
else { else {
stack.top.elements.push(update( stack.top.elements.push(update(
obj => obj[name] != null ? quote(obj[name]) obj => obj[name] != null ? quote(obj[name])
: hasOwnProperty(obj, name) ? "" : unknown(full), : hasOwnProp(obj, name) ? "" : unknown(full),
{ {
test: function test(obj) { test: function test(obj) {
return obj[name] != null && return obj[name] != null &&
@@ -509,7 +528,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
return obj.res; return obj.res;
} }
if (!pattern.contains("{")) if (!pattern.includes("{"))
return [pattern]; return [pattern];
let res = []; let res = [];
@@ -790,7 +809,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
try { try {
let xmlhttp = services.Xmlhttp(); let xmlhttp = services.Xmlhttp();
xmlhttp.mozBackgroundRequest = hasOwnProperty(params, "background") ? params.background : true; xmlhttp.mozBackgroundRequest = hasOwnProp(params, "background") ? params.background : true;
let async = params.callback || params.onload || params.onerror; let async = params.callback || params.onload || params.onerror;
if (async) { if (async) {
@@ -954,7 +973,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
}, },
// ripped from Firefox; modified // ripped from Firefox; modified
unsafeURI: Class.Memoize(() => util.regexp(String.replace(literal(function () /* unsafeURI: Class.Memoize(() => {
return util.regexp(
String.raw`
[ [
\s \s
// Invisible characters (bug 452979) // Invisible characters (bug 452979)
@@ -968,8 +989,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// Bidi formatting characters. (RFC 3987 sections 3.2 and 4.1 paragraph 6) // Bidi formatting characters. (RFC 3987 sections 3.2 and 4.1 paragraph 6)
U200E U200F U202A U202B U202C U202D U202E U200E U200F U202A U202B U202C U202D U202E
] ]
*/$), /U/g, "\\u"), `.replace(/U/g, "\\u"),
"gx")), "gx");
}),
losslessDecodeURI: function losslessDecodeURI(url) { losslessDecodeURI: function losslessDecodeURI(url) {
return url.split("%25").map(function (url) { return url.split("%25").map(function (url) {
// Non-UTF-8 compliant URLs cause "malformed URI sequence" errors. // Non-UTF-8 compliant URLs cause "malformed URI sequence" errors.
@@ -1303,7 +1326,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// Replace replacement <tokens>. // Replace replacement <tokens>.
if (tokens) if (tokens)
expr = String.replace(expr, /(\(?P)?<(\w+)>/g, expr = String.replace(expr, /(\(?P)?<(\w+)>/g,
(m, n1, n2) => !n1 && hasOwnProperty(tokens, n2) ? tokens[n2].dactylSource (m, n1, n2) => !n1 && hasOwnProp(tokens, n2) ? tokens[n2].dactylSource
|| tokens[n2].source || tokens[n2].source
|| tokens[n2] || tokens[n2]
: m); : m);
@@ -1717,11 +1740,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {function} func The function to call * @param {function} func The function to call
* @param {object} self The 'this' object for the function. * @param {object} self The 'this' object for the function.
*/ */
trapErrors: function trapErrors(func, self) { trapErrors: function trapErrors(func, self, ...args) {
try { try {
if (!callable(func)) if (!callable(func))
func = self[func]; func = self[func];
return func.apply(self || this, Array.slice(arguments, 2)); return func.apply(self || this, args);
} }
catch (e) { catch (e) {
this.reportError(e); this.reportError(e);
+2 -2
View File
@@ -31,8 +31,8 @@
<em:targetApplication> <em:targetApplication>
<Description <Description
em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}" em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
em:minVersion="31.0" em:minVersion="34.0"
em:maxVersion="41.*"/> em:maxVersion="46.*"/>
</em:targetApplication> </em:targetApplication>
</Description> </Description>
</RDF> </RDF>