1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-08 06:35:46 +01:00

Replace expression closures (getters).

Expression closures are to be axed. See https://bugzil.la/1083458.
This commit is contained in:
Doug Kearns
2015-05-27 04:42:30 +10:00
parent ce82387cdd
commit 6e8040286a
48 changed files with 808 additions and 532 deletions

View File

@@ -1028,8 +1028,8 @@ Class.prototype = {
*/
init: function c_init() {},
get instance() ({}),
set instance(val) Class.replaceProperty(this, "instance", val),
get instance() { return {}; },
set instance(val) { Class.replaceProperty(this, "instance", val); },
withSavedValues: function withSavedValues(names, callback, self) {
let vals = names.map(name => this[name]);
@@ -1173,7 +1173,7 @@ var closureHooks = {
return {
configurable: false,
writable: false,
get value() self.get(target, prop)
get value() { return self.get(target, prop); }
}
}
*/
@@ -1365,7 +1365,7 @@ var StructBase = Class("StructBase", Array, {
this[i] = arguments[i];
},
get toStringParams() this,
get toStringParams() { return this; },
clone: function struct_clone() this.constructor.apply(null, this.slice()),

View File

@@ -24,12 +24,14 @@ var Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "charse
var Keyword = Struct("keyword", "title", "icon", "url");
Bookmark.defaultValue("icon", function () BookmarkCache.getFavicon(this.url));
update(Bookmark.prototype, {
get extra() [
["keyword", this.keyword, "Keyword"],
["tags", this.tags.join(", "), "Tag"]
].filter(item => item[1]),
get extra() {
return [
["keyword", this.keyword, "Keyword"],
["tags", this.tags.join(", "), "Tag"]
].filter(item => item[1]);
},
get uri() newURI(this.url),
get uri() { return newURI(this.url); },
set uri(uri) {
let tags = this.tags;
this.tags = null;

View File

@@ -47,9 +47,9 @@ var Buffer = Module("Buffer", {
this.win = win;
},
get addPageInfoSection() Buffer.bound.addPageInfoSection,
get addPageInfoSection() { return Buffer.bound.addPageInfoSection; },
get pageInfo() Buffer.pageInfo,
get pageInfo() { return Buffer.pageInfo; },
// called when the active document is scrolled
_updateBufferPosition: function _updateBufferPosition() {
@@ -73,7 +73,7 @@ var Buffer = Module("Buffer", {
/**
* The load context of the window bound to this buffer.
*/
get loadContext() sanitizer.getContext(this.win),
get loadContext() { return sanitizer.getContext(this.win); },
/**
* Content preference methods.
@@ -211,10 +211,12 @@ var Buffer = Module("Buffer", {
/**
* @property {number} True when the buffer is fully loaded.
*/
get loaded() apply(Math, "min",
this.allFrames()
.map(frame => ["loading", "interactive", "complete"]
.indexOf(frame.document.readyState))),
get loaded() {
return apply(Math, "min",
this.allFrames()
.map(frame => ["loading", "interactive", "complete"]
.indexOf(frame.document.readyState)));
},
/**
* @property {Object} The local state store for the currently selected
@@ -231,7 +233,7 @@ var Buffer = Module("Buffer", {
localStorePrototype: memoize({
instance: {},
get jumps() [],
get jumps() { return []; },
jumpsIndex: -1
}),
@@ -251,11 +253,11 @@ var Buffer = Module("Buffer", {
/**
* @property {nsIURI} The current top-level document.
*/
get doc() this.win.document,
get doc() { return this.win.document; },
get docShell() util.docShell(this.win),
get docShell() { return util.docShell(this.win); },
get modules() this.topWindow.dactyl.modules,
get modules() { return this.topWindow.dactyl.modules; },
set modules(val) {},
topWindow: Class.Memoize(function () util.topWindow(this.win)),
@@ -263,7 +265,7 @@ var Buffer = Module("Buffer", {
/**
* @property {nsIURI} The current top-level document's URI.
*/
get uri() util.newURI(this.win.location.href),
get uri() { return util.newURI(this.win.location.href); },
/**
* @property {nsIURI} The current top-level document's URI, sans
@@ -280,20 +282,29 @@ var Buffer = Module("Buffer", {
* @property {nsIURI} The current top-level document's URI, sans any
* fragment identifier.
*/
get documentURI() this.doc.documentURIObject || util.newURI(this.doc.documentURI),
get documentURI() {
return this.doc.documentURIObject ||
util.newURI(this.doc.documentURI);
},
/**
* @property {string} The current top-level document's URL.
*/
get URL() update(new String(this.win.location.href), util.newURI(this.win.location.href)),
get URL() {
return update(new String(this.win.location.href),
util.newURI(this.win.location.href));
},
/**
* @property {number} The buffer's height in pixels.
*/
get pageHeight() this.win.innerHeight,
get pageHeight() { return this.win.innerHeight; },
get contentViewer() this.docShell.contentViewer
.QueryInterface(Ci.nsIMarkupDocumentViewer || Ci.nsIContentViewer),
get contentViewer() {
return this.docShell.contentViewer
.QueryInterface(Ci.nsIMarkupDocumentViewer ||
Ci.nsIContentViewer);
},
/**
* @property {number} The current browser's zoom level, as a
@@ -309,15 +320,15 @@ var Buffer = Module("Buffer", {
* @property {boolean} Whether the current browser is using full
* zoom, as opposed to text zoom.
*/
get fullZoom() this.ZoomManager.useFullZoom,
get fullZoom() { return this.ZoomManager.useFullZoom; },
set fullZoom(value) { this.setZoom(this.zoomLevel, value); },
get ZoomManager() this.topWindow.ZoomManager,
get ZoomManager() { return this.topWindow.ZoomManager; },
/**
* @property {string} The current document's title.
*/
get title() this.doc.title,
get title() { return this.doc.title; },
/**
* @property {number} The buffer's horizontal scroll percentile.
@@ -343,7 +354,9 @@ var Buffer = Module("Buffer", {
* @property {{ x: number, y: number }} The buffer's current scroll position
* as reported by {@link Buffer.getScrollPosition}.
*/
get scrollPosition() Buffer.getScrollPosition(this.findScrollable(0, false)),
get scrollPosition() {
return Buffer.getScrollPosition(this.findScrollable(0, false));
},
/**
* Returns a list of all frames in the given window or current buffer.
@@ -380,7 +393,7 @@ var Buffer = Module("Buffer", {
*
* @returns {string}
*/
get currentWord() Buffer.currentWord(this.focusedFrame),
get currentWord() { return Buffer.currentWord(this.focusedFrame); },
getCurrentWord: deprecated("buffer.currentWord", function getCurrentWord() Buffer.currentWord(this.focusedFrame, true)),
/**
@@ -694,13 +707,15 @@ var Buffer = Module("Buffer", {
/**
* @property {nsISelection} The current document's normal selection.
*/
get selection() this.win.getSelection(),
get selection() { return this.win.getSelection(); },
/**
* @property {nsISelectionController} The current document's selection
* controller.
*/
get selectionController() util.selectionController(this.focusedFrame),
get selectionController() {
return util.selectionController(this.focusedFrame);
},
/**
* @property {string|null} The canonical short URL for the current
@@ -1458,26 +1473,34 @@ var Buffer = Module("Buffer", {
win: elem.defaultView || elem.ownerDocument.defaultView,
get clientWidth() this.win.innerWidth,
get clientHeight() this.win.innerHeight,
get clientWidth() { return this.win.innerWidth; },
get clientHeight() { return this.win.innerHeight; },
get scrollWidth() this.win.scrollMaxX + this.win.innerWidth,
get scrollHeight() this.win.scrollMaxY + this.win.innerHeight,
get scrollWidth() {
return this.win.scrollMaxX + this.win.innerWidth;
},
get scrollHeight() {
return this.win.scrollMaxY + this.win.innerHeight;
},
get scrollLeftMax() this.win.scrollMaxX,
get scrollRightMax() this.win.scrollMaxY,
get scrollLeftMax() { return this.win.scrollMaxX; },
get scrollRightMax() { return this.win.scrollMaxY; },
get scrollLeft() this.win.scrollX,
set scrollLeft(val) { this.win.scrollTo(val, this.win.scrollY); },
get scrollLeft() { return this.win.scrollX; },
set scrollLeft(val) {
this.win.scrollTo(val, this.win.scrollY);
},
get scrollTop() this.win.scrollY,
set scrollTop(val) { this.win.scrollTo(this.win.scrollX, val); }
get scrollTop() { return this.win.scrollY; },
set scrollTop(val) {
this.win.scrollTo(this.win.scrollX, val);
}
};
return elem;
},
get ZOOM_MIN() prefs.get("zoom.minPercent"),
get ZOOM_MAX() prefs.get("zoom.maxPercent"),
get ZOOM_MIN() { return prefs.get("zoom.minPercent"); },
get ZOOM_MAX() { return prefs.get("zoom.maxPercent"); },
setZoom: deprecated("buffer.setZoom",
function setZoom(...args) apply(overlay.activeModules.buffer, "setZoom", args)),
@@ -2565,7 +2588,7 @@ var Buffer = Module("Buffer", {
options.add(["pageinfo", "pa"],
"Define which sections are shown by the :pageinfo command",
"charlist", "gesfm",
{ get values() values(Buffer.pageInfo).toObject() });
{ get values() { return values(Buffer.pageInfo).toObject(); }});
options.add(["scroll", "scr"],
"Number of lines to scroll with <C-u> and <C-d> commands",

View File

@@ -97,7 +97,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
return this._cacheReader;
},
get inQueue() this._cacheWriter && this._cacheWriter.inQueue,
get inQueue() { return this._cacheWriter && this._cacheWriter.inQueue; },
getCacheWriter: function () {
if (!this._cacheWriter)

View File

@@ -140,13 +140,15 @@ var Command = Class("Command", {
this.update(extraInfo);
},
get toStringParams() [this.name, this.hive.name],
get toStringParams() { return [this.name, this.hive.name]; },
get identifier() this.hive.prefix + this.name,
get identifier() { return this.hive.prefix + this.name; },
get helpTag() ":" + this.name,
get helpTag() { return ":" + this.name; },
get lastCommand() this._lastCommand || this.modules.commandline.command,
get lastCommand() {
return this._lastCommand || this.modules.commandline.command;
},
set lastCommand(val) { this._lastCommand = val; },
/**
@@ -326,7 +328,10 @@ var Command = Class("Command", {
has: function AP_has(opt) hasOwnProperty(this.explicitOpts, opt)
|| typeof opt === "number" && hasOwnProperty(this, opt),
get literalArg() this.command.literal != null && this[this.command.literal] || "",
get literalArg() {
let { literal } = this.command;
return literal != null && this[literal] || "";
},
// TODO: string: Class.Memoize(function () { ... }),
@@ -431,8 +436,8 @@ var Command = Class("Command", {
// Prototype.
var Ex = Module("Ex", {
Local: function Local(dactyl, modules, window) ({
get commands() modules.commands,
get context() modules.contexts.context
get commands() { return modules.commands; },
get context() { return modules.contexts.context; }
}),
_args: function E_args(cmd, args) {
@@ -528,7 +533,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
}
},
get cacheKey() "commands/hives/" + this.name + ".json",
get cacheKey() { return "commands/hives/" + this.name + ".json"; },
/** @property {Iterator(Command)} @private */
"@@iterator": function __iterator__() {
@@ -678,13 +683,15 @@ var Commands = Module("commands", {
this.modules.moduleManager.initDependencies("commands");
},
get context() contexts.context,
get context() { return contexts.context; },
get readHeredoc() modules.io.readHeredoc,
get readHeredoc() { return modules.io.readHeredoc; },
get allHives() contexts.allGroups.commands,
get allHives() { return contexts.allGroups.commands; },
get userHives() this.allHives.filter(h => h !== this.builtin),
get userHives() {
return this.allHives.filter(h => h !== this.builtin);
},
/**
* Executes an Ex command script.
@@ -1391,10 +1398,10 @@ var Commands = Module("commands", {
},
/** @property */
get complQuote() Commands.complQuote,
get complQuote() { return Commands.complQuote; },
/** @property */
get quoteArg() Commands.quoteArg // XXX: better somewhere else?
get quoteArg() { return Commands.quoteArg; } // XXX: better somewhere else?
}, {
// returns [count, parsed_argument]

View File

@@ -219,9 +219,11 @@ var CompletionContext = Class("CompletionContext", {
delete this.__title;
return this._title = val;
},
get title() this.__title,
get title() { return this.__title; },
get activeContexts() this.contextList.filter(function f(c) c.items.length),
get activeContexts() {
return this.contextList.filter(function f(c) c.items.length);
},
// Temporary
/**
@@ -248,17 +250,19 @@ var CompletionContext = Class("CompletionContext", {
this.cache.allItemsResult = memoize({
start: minStart,
get longestSubstring() self.longestAllSubstring,
get longestSubstring() { return self.longestAllSubstring; },
get items() Ary.flatten(self.activeContexts.map(function m(context) {
let prefix = self.value.substring(minStart, context.offset);
get items() {
return Ary.flatten(self.activeContexts.map(function m(context) {
let prefix = self.value.substring(minStart, context.offset);
return context.items.map(function m(item) ({
text: prefix + item.text,
result: prefix + item.result,
__proto__: item
return context.items.map(function m(item) ({
text: prefix + item.text,
result: prefix + item.result,
__proto__: item
}));
}));
}))
}
});
return this.cache.allItemsResult;
@@ -292,13 +296,13 @@ var CompletionContext = Class("CompletionContext", {
return this.allSubstrings.reduce(function r(a, b) a.length > b.length ? a : b, "");
},
get caret() this._caret - this.offset,
set caret(val) this._caret = val + this.offset,
get caret() { return this._caret - this.offset; },
set caret(val) { this._caret = val + this.offset; },
get compare() this._compare || function compare() 0,
set compare(val) this._compare = val,
get compare() { return this._compare || function compare() 0; },
set compare(val) { this._compare = val; },
get completions() this._completions || [],
get completions() { return this._completions || []; },
set completions(items) {
if (items && isArray(items.array))
items = items.array;
@@ -320,24 +324,29 @@ var CompletionContext = Class("CompletionContext", {
util.trapErrors("onUpdate", this);
},
get createRow() this._createRow || template.completionRow, // XXX
set createRow(createRow) this._createRow = createRow,
get createRow() { return this._createRow || template.completionRow; }, // XXX
set createRow(createRow) { return this._createRow = createRow; },
get filterFunc() this._filterFunc || util.identity,
set filterFunc(val) this._filterFunc = val,
get filterFunc() { return this._filterFunc || util.identity; },
set filterFunc(val) { this._filterFunc = val; },
get filter() this._filter != null ? this._filter : this.value.substr(this.offset, this.caret),
get filter() {
return this._filter != null ? this._filter
: this.value.substr(this.offset, this.caret);
},
set filter(val) {
delete this.ignoreCase;
return this._filter = val;
},
get format() ({
anchored: this.anchored,
title: this.title,
keys: this.keys,
process: this.process
}),
get format() {
return {
anchored: this.anchored,
title: this.title,
keys: this.keys,
process: this.process
};
},
set format(format) {
this.anchored = format.anchored,
this.title = format.title || this.title;
@@ -350,8 +359,8 @@ var CompletionContext = Class("CompletionContext", {
* The message displayed at the head of the completions for the
* current context.
*/
get message() this._message || (this.waitingForTab && this.hasItems !== false ? _("completion.waitingFor", "<Tab>") : null),
set message(val) this._message = val,
get message() { return this._message || (this.waitingForTab && this.hasItems !== false ? _("completion.waitingFor", "<Tab>") : null); },
set message(val) { this._message = val; },
/**
* The prototype object for items returned by {@link items}.
@@ -387,7 +396,7 @@ var CompletionContext = Class("CompletionContext", {
* must be regenerated. May be set to true to invalidate the current
* completions.
*/
get regenerate() this._generate && (!this.completions || !this.itemCache[this.key] || this._cache.offset != this.offset),
get regenerate() { return this._generate && (!this.completions || !this.itemCache[this.key] || this._cache.offset != this.offset); },
set regenerate(val) { if (val) delete this.itemCache[this.key]; },
/**
@@ -396,7 +405,7 @@ var CompletionContext = Class("CompletionContext", {
* completions are linked to the value in {@link #key} and may be
* invalidated by setting the {@link #regenerate} property.
*/
get generate() this._generate || null,
get generate() { return this._generate || null; },
set generate(arg) {
this.hasItems = true;
this._generate = arg;
@@ -900,13 +909,13 @@ var Completion = Module("completion", {
init: function init() {
},
get setFunctionCompleter() JavaScript.setCompleter, // Backward compatibility
get setFunctionCompleter() { return JavaScript.setCompleter; }, // Backward compatibility
Local: function Local(dactyl, modules, window) ({
urlCompleters: {},
get modules() modules,
get options() modules.options,
get modules() { return modules; },
get options() { return modules.options; },
// FIXME
_runCompleter: function _runCompleter(name, filter, maxItems, ...args) {
@@ -1054,7 +1063,7 @@ var Completion = Module("completion", {
for (i of util.range(0, result.matchCount))
];
}),
get onUpdateSearchResult() this.onSearchResult
get onUpdateSearchResult() { return this.onSearchResult; }
});
running[provider] = true;
}
@@ -1118,7 +1127,7 @@ var Completion = Module("completion", {
return init.superapply(this, arguments);
},
get options() this.modules.options
get options() { return this.modules.options; }
});
},
commands: function initCommands(dactyl, modules, window) {

View File

@@ -25,11 +25,11 @@ lazyRequire("util", ["util"]);
function AboutHandler() {}
AboutHandler.prototype = {
get classDescription() "About " + config.appName + " Page",
get classDescription() { return "About " + config.appName + " Page"; },
classID: Components.ID("81495d80-89ee-4c36-a88d-ea7c4e5ac63f"),
get contractID() services.ABOUT + config.name,
get contractID() { return services.ABOUT + config.name; },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
@@ -79,7 +79,7 @@ var ConfigBase = Class("ConfigBase", {
});
},
get prefs() localPrefs,
get prefs() { return localPrefs; },
has: function (feature) this.features.has(feature),
@@ -194,14 +194,14 @@ var ConfigBase = Class("ConfigBase", {
};
},
get addonID() this.name + "@dactyl.googlecode.com",
get addonID() { return this.name + "@dactyl.googlecode.com"; },
addon: Class.Memoize(function () {
return (JSMLoader.bootstrap || {}).addon ||
AddonManager.getAddonByID(this.addonID);
}),
get styleableChrome() Object.keys(this.overlays),
get styleableChrome() { return Object.keys(this.overlays); },
/**
* The current application locale.
@@ -335,17 +335,23 @@ var ConfigBase = Class("ConfigBase", {
* @property {string} The normalised name of the OS. This is one of
* "Windows", "Mac OS X" or "Unix".
*/
get name() this.isWindows ? "Windows" : this.isMacOSX ? "Mac OS X" : "Unix",
get name() {
return this.isWindows ? "Windows"
: this.isMacOSX ? "Mac OS X"
: "Unix";
},
/** @property {boolean} True if the OS is Windows. */
get isWindows() this._arch == "WINNT",
get isWindows() { return this._arch == "WINNT"; },
/** @property {boolean} True if the OS is Mac OS X. */
get isMacOSX() this._arch == "Darwin",
get isMacOSX() { return this._arch == "Darwin"; },
/** @property {boolean} True if the OS is some other *nix variant. */
get isUnix() !this.isWindows,
get isUnix() { return !this.isWindows; },
/** @property {RegExp} A RegExp which matches illegal characters in path components. */
get illegalCharacters() this.isWindows ? /[<>:"/\\|?*\x00-\x1f]/g : /[\/\x00]/g,
get illegalCharacters() {
return this.isWindows ? /[<>:"/\\|?*\x00-\x1f]/g : /[\/\x00]/g;
},
get pathListSep() this.isWindows ? ";" : ":"
get pathListSep() { return this.isWindows ? ";" : ":"; }
}),
/**
@@ -407,7 +413,7 @@ var ConfigBase = Class("ConfigBase", {
return _("dactyl.created", "@DATE@");
}),
get fileExt() this.name.slice(0, -6),
get fileExt() { return this.name.slice(0, -6); },
dtd: Class.Memoize(function ()
iter(this.dtdExtra,
@@ -416,13 +422,15 @@ var ConfigBase = Class("ConfigBase", {
.toObject()),
dtdDactyl: memoize({
get name() config.name,
get home() "http://5digits.org/",
get apphome() this.home + this.name,
get name() { return config.name; },
get home() { return "http://5digits.org/"; },
get apphome() { return this.home + this.name; },
code: "http://code.google.com/p/dactyl/",
get issues() this.home + "bug/" + this.name,
get plugins() "http://5digits.org/" + this.name + "/plugins",
get faq() this.home + this.name + "/faq",
get issues() { return this.home + "bug/" + this.name; },
get plugins() {
return "http://5digits.org/" + this.name + "/plugins";
},
get faq() { return this.home + this.name + "/faq"; },
"list.mailto": Class.Memoize(() => config.name + "@googlegroups.com"),
"list.href": Class.Memoize(() => "http://groups.google.com/group/" + config.name),
@@ -483,18 +491,18 @@ var ConfigBase = Class("ConfigBase", {
util.overlayWindow(window, { append: append });
},
get window() window,
get window() { return window; },
get document() document,
get document() { return document; },
ids: Class.Update({
get commandContainer() document.documentElement.id
get commandContainer() { return document.documentElement.id; }
}),
browser: Class.Memoize(() => window.gBrowser),
tabbrowser: Class.Memoize(() => window.gBrowser),
get browserModes() [modules.modes.NORMAL],
get browserModes() { return [modules.modes.NORMAL]; },
/**
* @property {string} The ID of the application's main XUL window.
@@ -505,7 +513,9 @@ var ConfigBase = Class("ConfigBase", {
* @property {number} The height (px) that is available to the output
* window.
*/
get outputHeight() this.browser.mPanelContainer.boxObject.height,
get outputHeight() {
return this.browser.mPanelContainer.boxObject.height;
},
tabStrip: Class.Memoize(function () document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer)
}),
@@ -556,7 +566,7 @@ var ConfigBase = Class("ConfigBase", {
* @property {string} The file extension used for command script files.
* This is the name string sans "dactyl".
*/
get fileExtension() this.name.slice(0, -6),
get fileExtension() { return this.name.slice(0, -6); },
guioptions: {},

View File

@@ -27,10 +27,12 @@ var Group = Class("Group", {
this.children = [];
},
get contexts() this.modules.contexts,
get contexts() { return this.modules.contexts; },
set lastDocument(val) { this._lastDocument = util.weakReference(val); },
get lastDocument() this._lastDocument && this._lastDocument.get(),
get lastDocument() {
return this._lastDocument && this._lastDocument.get();
},
modifiable: true,
@@ -60,9 +62,11 @@ var Group = Class("Group", {
return update(res, this.argsExtra(res), args);
},
get toStringParams() [this.name],
get toStringParams() { return [this.name]; },
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0
get builtin() {
return this.modules.contexts.builtinGroups.indexOf(this) >= 0;
}
}, {
compileFilter: function (patterns, default_=false) {
function siteFilter(uri) {
@@ -132,13 +136,17 @@ var Contexts = Module("contexts", {
});
},
get toStringParams() [this.name],
get toStringParams() { return [this.name]; },
names: ["-group", "-g"],
description: "Group to which to add",
get default() (contexts.context && contexts.context.group || contexts.user)[this.name],
get default() {
return (contexts.context &&
contexts.context.group ||
contexts.user)[this.name];
},
completer: function (context) modules.completion.group(context)
});
@@ -171,7 +179,9 @@ var Contexts = Module("contexts", {
}
},
Group: Class("Group", Group, { modules: modules, get hiveMap() modules.contexts.hives }),
Group: Class("Group", Group,
{ modules: modules,
get hiveMap() { return modules.contexts.hives; }}),
Hives: Class("Hives", Class.Property, {
init: function init(name, constructor) {
@@ -203,7 +213,7 @@ var Contexts = Module("contexts", {
if (hasOwnProperty(group, name))]);
},
get toStringParams() [this.name, this.Hive]
get toStringParams() { return [this.name, this.Hive]; }
})
}),
@@ -330,7 +340,7 @@ var Contexts = Module("contexts", {
CONTEXT: Const(self),
get isGlobalModule() true,
get isGlobalModule() { return true; },
set isGlobalModule(val) {
util.assert(val, "Loading non-global module as global",
false);
@@ -580,27 +590,27 @@ var Contexts = Module("contexts", {
cleanup: function cleanup() {},
destroy: function destroy() {},
get modifiable() this.group.modifiable,
get modifiable() { return this.group.modifiable; },
get argsExtra() this.group.argsExtra,
get makeArgs() this.group.makeArgs,
get builtin() this.group.builtin,
get argsExtra() { return this.group.argsExtra; },
get makeArgs() { return this.group.makeArgs; },
get builtin() { return this.group.builtin; },
get name() this.group.name,
set name(val) this.group.name = val,
get name() { return this.group.name; },
set name(val) { this.group.name = val; },
get description() this.group.description,
set description(val) this.group.description = val,
get description() { return this.group.description; },
set description(val) { this.group.description = val; },
get filter() this.group.filter,
set filter(val) this.group.filter = val,
get filter() { return this.group.filter; },
set filter(val) { this.group.filter = val; },
get persist() this.group.persist,
set persist(val) this.group.persist = val,
get persist() { return this.group.persist; },
set persist(val) { this.group.persist = val; },
prefix: Class.Memoize(function () this.name === "builtin" ? "" : this.name + ":"),
get toStringParams() [this.name]
get toStringParams() { return [this.name]; }
})
}, {
commands: function initCommands(dactyl, modules, window) {

View File

@@ -98,8 +98,11 @@ var DOM = Class("DOM", {
}.call(this);
},
get document() this._document || this[0] && (this[0].ownerDocument || this[0].document || this[0]),
set document(val) this._document = val,
get document() {
return this._document || this[0] &&
(this[0].ownerDocument || this[0].document || this[0]);
},
set document(val) { this._document = val; },
attrHooks: {
"": {
@@ -240,34 +243,50 @@ var DOM = Class("DOM", {
return false;
},
get parent() this.map(elem => elem.parentNode, this),
get parent() { return this.map(elem => elem.parentNode, this); },
get offsetParent() this.map(function (elem) {
do {
var parent = elem.offsetParent;
if (parent instanceof Ci.nsIDOMElement && DOM(parent).position != "static")
return parent;
}
while (parent);
}, this),
get offsetParent() {
return this.map(function (elem) {
do {
var parent = elem.offsetParent;
if (parent instanceof Ci.nsIDOMElement && DOM(parent).position != "static")
return parent;
}
while (parent);
}, this);
},
get ancestors() this.all(elem => elem.parentNode),
get ancestors() { return this.all(elem => elem.parentNode); },
get children() this.map(elem => Array.filter(elem.childNodes,
e => e instanceof Ci.nsIDOMElement),
this),
get children() {
return this.map(
elem => Array.filter(elem.childNodes,
e => e instanceof Ci.nsIDOMElement),
this);
},
get contents() this.map(elem => elem.childNodes, this),
get contents() { return this.map(elem => elem.childNodes, this); },
get siblings() this.map(elem => Array.filter(elem.parentNode.childNodes,
e => e != elem && e instanceof Ci.nsIDOMElement),
this),
get siblings() {
return this.map(
elem => Array.filter(elem.parentNode.childNodes,
e => e != elem && e instanceof Ci.nsIDOMElement),
this);
},
get siblingsBefore() this.all(elem => elem.previousElementSibling),
get siblingsAfter() this.all(elem => elem.nextElementSibling),
get siblingsBefore() {
return this.all(elem => elem.previousElementSibling);
},
get siblingsAfter() {
return this.all(elem => elem.nextElementSibling);
},
get allSiblingsBefore() this.all(elem => elem.previousSibling),
get allSiblingsAfter() this.all(elem => elem.nextSibling),
get allSiblingsBefore() {
return this.all(elem => elem.previousSibling);
},
get allSiblingsAfter() {
return this.all(elem => elem.nextSibling);
},
get class() {
let self = this;
@@ -275,8 +294,8 @@ var DOM = Class("DOM", {
return {
toString: function () self[0].className,
get list() Array.slice(self[0].classList),
set list(val) self.attr("class", val.join(" ")),
get list() { return Array.slice(self[0].classList); },
set list(val) { self.attr("class", val.join(" ")); },
each: function each(meth, arg) {
return self.each(function (elem) {
@@ -335,13 +354,15 @@ var DOM = Class("DOM", {
};
},
get rect() this[0] instanceof Ci.nsIDOMWindow ? { width: this[0].scrollMaxX + this[0].innerWidth,
get rect() {
return this[0] instanceof Ci.nsIDOMWindow ? { width: this[0].scrollMaxX + this[0].innerWidth,
height: this[0].scrollMaxY + this[0].innerHeight,
get right() this.width + this.left,
get bottom() this.height + this.top,
top: -this[0].scrollY,
left: -this[0].scrollX } :
this[0] ? this[0].getBoundingClientRect() : {},
this[0] ? this[0].getBoundingClientRect() : {};
},
get viewport() {
let node = this[0];
@@ -350,8 +371,8 @@ var DOM = Class("DOM", {
if (node instanceof Ci.nsIDOMWindow)
return {
get width() this.right - this.left,
get height() this.bottom - this.top,
get width() { return this.right - this.left; },
get height() { return this.bottom - this.top; },
bottom: node.innerHeight,
right: node.innerWidth,
top: 0, left: 0
@@ -362,9 +383,9 @@ var DOM = Class("DOM", {
width: node.clientWidth,
height: node.clientHeight,
top: r.top + node.clientTop,
get bottom() this.top + this.height,
get bottom() { return this.top + this.height; },
left: r.left + node.clientLeft,
get right() this.left + this.width
get right() { return this.left + this.width; }
};
},
@@ -436,12 +457,18 @@ var DOM = Class("DOM", {
return editor;
},
get isEditable() !!this.editor || this[0] instanceof Ci.nsIDOMElement && this.style.MozUserModify == "read-write",
get isEditable() {
return !!this.editor ||
this[0] instanceof Ci.nsIDOMElement &&
this.style.MozUserModify == "read-write";
},
get isInput() isinstance(this[0], [Ci.nsIDOMHTMLInputElement,
Ci.nsIDOMHTMLTextAreaElement,
Ci.nsIDOMXULTextBoxElement])
&& this.isEditable,
get isInput() {
return isinstance(this[0], [Ci.nsIDOMHTMLInputElement,
Ci.nsIDOMHTMLTextAreaElement,
Ci.nsIDOMXULTextBoxElement])
&& this.isEditable;
},
/**
* Returns an object representing a Node's computed CSS style.
@@ -987,10 +1014,14 @@ var DOM = Class("DOM", {
bubbles: true, cancelable: true,
view: doc.defaultView,
detail: 1,
get screenX() this.view.mozInnerScreenX
+ Math.max(0, this.clientX + (DOM(target || opts.target).rect.left || 0)),
get screenY() this.view.mozInnerScreenY
+ Math.max(0, this.clientY + (DOM(target || opts.target).rect.top || 0)),
get screenX() {
return this.view.mozInnerScreenX
+ Math.max(0, this.clientX + (DOM(target || opts.target).rect.left || 0));
},
get screenY() {
return this.view.mozInnerScreenY
+ Math.max(0, this.clientY + (DOM(target || opts.target).rect.top || 0));
},
clientX: 0,
clientY: 0,
ctrlKey: false, altKey: false, shiftKey: false, metaKey: false,
@@ -1847,8 +1878,8 @@ var DOM = Class("DOM", {
let res = {
iterateNext: function () result.iterateNext(),
get resultType() result.resultType,
get snapshotLength() result.snapshotLength,
get resultType() { return result.resultType; },
get snapshotLength() { return result.snapshotLength; },
snapshotItem: function (i) result.snapshotItem(i)
};
if (asIterator)

View File

@@ -68,24 +68,29 @@ var Download = Class("Download", {
return this;
},
get active() !this.stopped,
get active() { return !this.stopped; },
get targetFile() File(this.download.target.path),
get targetFile() { return File(this.download.target.path); },
get displayName() this.targetFile.leafName,
get displayName() { return this.targetFile.leafName; },
get status() states[this.state],
get status() { return states[this.state]; },
inState: function inState(states) states.indexOf(this.status) >= 0,
allowedCommands: Class.Memoize(function () {
let self = this;
return {
get delete() !self.active && (self.targetFile.exists() || self.hasPartialData),
get launch() self.targetFile.exists() && self.succeeded,
get stop() self.active,
get remove() !self.active,
get resume() self.canceled
get delete() {
return !self.active &&
(self.targetFile.exists() || self.hasPartialData);
},
get launch() {
return self.targetFile.exists() && self.succeeded;
},
get stop() { return self.active; },
get remove() { return !self.active; },
get resume() { return self.canceled; }
};
}),
@@ -318,7 +323,9 @@ var DownloadList = Class("DownloadList",
allowedCommands: Class.Memoize(function () {
let self = this;
return {
get clear() iter(self.downloads.values()).some(dl => dl.allowedCommands.remove)
get clear() {
return iter(self.downloads.values()).some(dl => dl.allowedCommands.remove);
}
};
}),
@@ -482,7 +489,9 @@ var Downloads_ = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
names: ["-sort", "-s"],
description: "Sort order (see 'downloadsort')",
type: CommandOption.LIST,
get default() modules.options["downloadsort"],
get default() {
return modules.options["downloadsort"];
},
completer: function (context, args) modules.options.get("downloadsort").completer(context, { values: args["-sort"] }),
validator: function (value) modules.options.get("downloadsort").validator(value)
}

View File

@@ -44,8 +44,10 @@ var RangeFinder = Module("rangefinder", {
return this.rangeFind = null;
return find;
},
set rangeFind(val) overlay.setData(this.content.document,
"range-find", val)
set rangeFind(val) {
overlay.setData(this.content.document,
"range-find", val);
}
}),
init: function init() {
@@ -64,9 +66,9 @@ var RangeFinder = Module("rangefinder", {
}
},
get commandline() this.modules.commandline,
get modes() this.modules.modes,
get options() this.modules.options,
get commandline() { return this.modules.commandline; },
get modes() { return this.modules.modes; },
get options() { return this.modules.options; },
openPrompt: function openPrompt(mode) {
this.modules.marks.push();
@@ -256,12 +258,14 @@ var RangeFinder = Module("rangefinder", {
historyKey: "find",
get prompt() this.mode === modules.modes.FIND_BACKWARD ? "?" : "/",
get prompt() {
return this.mode === modules.modes.FIND_BACKWARD ? "?" : "/";
},
get onCancel() modules.rangefinder.bound.onCancel,
get onChange() modules.rangefinder.bound.onChange,
get onHistory() modules.rangefinder.bound.onHistory,
get onSubmit() modules.rangefinder.bound.onSubmit
get onCancel() { return modules.rangefinder.bound.onCancel; },
get onChange() { return modules.rangefinder.bound.onChange; },
get onHistory() { return modules.rangefinder.bound.onHistory; },
get onSubmit() { return modules.rangefinder.bound.onSubmit; }
});
},
mappings: function initMappings(dactyl, modules, window) {
@@ -384,17 +388,19 @@ var RangeFind = Class("RangeFind", {
this.lastString = "";
},
get store() overlay.getData(this.content.document, "buffer", Object),
get store() {
return overlay.getData(this.content.document, "buffer", Object);
},
get backward() this.finder.findBackwards,
set backward(val) this.finder.findBackwards = val,
get backward() { return this.finder.findBackwards; },
set backward(val) { this.finder.findBackwards = val; },
get matchCase() this.finder.caseSensitive,
set matchCase(val) this.finder.caseSensitive = Boolean(val),
get matchCase() { return this.finder.caseSensitive; },
set matchCase(val) { this.finder.caseSensitive = Boolean(val); },
get findString() this.lastString,
get findString() { return this.lastString; },
get flags() this.matchCase ? "" : "i",
get flags() { return this.matchCase ? "" : "i"; },
get selectedRange() {
let win = this.store.focusedFrame && this.store.focusedFrame.get() || this.content;
@@ -707,8 +713,10 @@ var RangeFind = Class("RangeFind", {
return range;
},
get stale() this._stale || this.baseDocument.get() != this.content.document,
set stale(val) this._stale = val,
get stale() {
return this._stale || this.baseDocument.get() != this.content.document;
},
set stale(val) { this._stale = val; },
addListeners: function addListeners() {
for (let range of this.ranges)
@@ -766,9 +774,12 @@ var RangeFind = Class("RangeFind", {
}
},
get selectionController() this.docShell
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
.QueryInterface(Ci.nsISelectionController),
get selectionController() {
return this.docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsISelectionDisplay)
.QueryInterface(Ci.nsISelectionController);
},
get selection() {
try {
return this.selectionController.getSelection(Ci.nsISelectionController.SELECTION_NORMAL);

View File

@@ -215,11 +215,11 @@ var Help = Module("Help", {
cache.flushEntry(entry, time);
},
get data() this._data || cache.get("help.json"),
get data() { return this._data || cache.get("help.json"); },
get files() this.data.files,
get overlays() this.data.overlays,
get tags() this.data.tags,
get files() { return this.data.files; },
get overlays() { return this.data.overlays; },
get tags() { return this.data.tags; },
Local: function Local(dactyl, modules, window) ({
init: function init() {

View File

@@ -63,9 +63,15 @@ Highlight.defaultValue("extends", function () this.defaultExtends);
Highlight.defaultValue("value", function () this.defaultValue);
update(Highlight.prototype, {
get base() this.baseClass != this.class && highlight.highlight[this.baseClass] || null,
get base() {
return this.baseClass != this.class &&
highlight.highlight[this.baseClass] ||
null;
},
get bases() Ary.compact(this.extends.map(name => highlight.get(name))),
get bases() {
return Ary.compact(this.extends.map(name => highlight.get(name)));
},
get inheritedCSS() {
if (this.gettingCSS)
@@ -79,9 +85,9 @@ update(Highlight.prototype, {
}
},
get css() this.selector + "{" + this.cssText + "}",
get css() { return this.selector + "{" + this.cssText + "}"; },
get cssText() this.inheritedCSS + this.value,
get cssText() { return this.inheritedCSS + this.value; },
toString: function () "Highlight(" + this.class + ")\n\t" +
[k + ": " + JSON.stringify(String(v))

View File

@@ -56,7 +56,7 @@ var IO = Module("io", {
historyKey: "file",
get mode() modules.modes.FILE_INPUT,
get mode() { return modules.modes.FILE_INPUT; },
complete: function (context) {
if (this.completer)
@@ -1161,8 +1161,10 @@ unlet s:cpo_save
"List of directories searched when executing :cd",
"stringlist", ["."].concat(services.environment.get("CDPATH").split(/[:;]/).filter(util.identity)).join(","),
{
get files() this.value.map(path => File(path, modules.io.cwd))
.filter(dir => dir.exists()),
get files() {
return this.value.map(path => File(path, modules.io.cwd))
.filter(dir => dir.exists());
},
setter: function (value) File.expandPathList(value)
});
@@ -1170,8 +1172,10 @@ unlet s:cpo_save
"List of directories searched for runtime files",
"stringlist", IO.runtimePath,
{
get files() this.value.map(path => File(path, modules.io.cwd))
.filter(dir => dir.exists())
get files() {
return this.value.map(path => File(path, modules.io.cwd))
.filter(dir => dir.exists());
}
});
options.add(["shell", "sh"],

View File

@@ -448,7 +448,7 @@ var JavaScript = Module("javascript", {
return this.evalled(key);
},
get cache() this.context.cache,
get cache() { return this.context.cache; },
complete: function _complete(context) {
const self = this;
@@ -695,7 +695,7 @@ var JavaScript = Module("javascript", {
},
completion: function (dactyl, modules, window) {
update(modules.completion, {
get javascript() modules.javascript.bound.complete,
get javascript() { return modules.javascript.bound.complete; },
javascriptCompleter: JavaScript // Backwards compatibility
});
},
@@ -808,7 +808,7 @@ var JavaScript = Module("javascript", {
mode: modes.REPL,
get completionList() this.widgets.statusbar.commandline.id,
get completionList() { return this.widgets.statusbar.commandline.id; },
accept: function accept() {
dactyl.trapErrors(function () { this.repl.addOutput(this.command); }, this);

View File

@@ -176,11 +176,15 @@ var Modules = function Modules(window) {
newContext: newContext,
get ownPropertyValues() Ary.compact(
get ownPropertyValues() {
return Ary.compact(
Object.getOwnPropertyNames(this)
.map(name => Object.getOwnPropertyDescriptor(this, name).value)),
.map(name => Object.getOwnPropertyDescriptor(this, name).value));
},
get moduleList() this.ownPropertyValues.filter(mod => (mod instanceof this.ModuleBase || mod.isLocalModule))
get moduleList() {
return this.ownPropertyValues.filter(mod => (mod instanceof this.ModuleBase || mod.isLocalModule));
}
});
modules.plugins = create(modules);

View File

@@ -72,16 +72,16 @@ var Option = Class("Option", {
*/
description: Messages.Localized(""),
get helpTag() "'" + this.name + "'",
get helpTag() { return "'" + this.name + "'"; },
initValue: function initValue() {
util.trapErrors(() => { this.value = this.value; });
},
get isDefault() this.stringValue === this.stringDefaultValue,
get isDefault() { return this.stringValue === this.stringDefaultValue; },
/** @property {value} The value to reset this option to at cleanup time. */
get cleanupValue() options.cleanupPrefs.get(this.name),
get cleanupValue() { return options.cleanupPrefs.get(this.name); },
set cleanupValue(value) {
if (options.cleanupPrefs.get(this.name) == null)
options.cleanupPrefs.set(this.name, value);
@@ -194,14 +194,14 @@ var Option = Class("Option", {
* or if no local value is set, this is equal to the
* (@link #globalValue).
*/
get value() this.get(),
set value(val) this.set(val),
get value() { return this.get(); },
set value(val) { this.set(val); },
get stringValue() this.stringify(this.value),
set stringValue(value) this.value = this.parse(value),
get stringValue() { return this.stringify(this.value); },
set stringValue(value) { this.value = this.parse(value); },
get stringDefaultValue() this.stringify(this.defaultValue),
set stringDefaultValue(val) this.defaultValue = this.parse(val),
get stringDefaultValue() { return this.stringify(this.defaultValue); },
set stringDefaultValue(val) { this.defaultValue = this.parse(val); },
getKey: function getKey(key) undefined,
@@ -411,8 +411,11 @@ var Option = Class("Option", {
* @property {number} Returns the timestamp when the option's value was
* last changed.
*/
get lastSet() options.store.get(this.name).time,
set lastSet(val) { options.store.set(this.name, { value: this.globalValue, time: Date.now() }); },
get lastSet() { return options.store.get(this.name).time; },
set lastSet(val) {
options.store.set(this.name,
{ value: this.globalValue, time: Date.now() });
},
/**
* @property {nsIFile} The script in which this option was last set. null
@@ -486,7 +489,7 @@ var Option = Class("Option", {
getKey: {
stringlist: function stringlist(k) this.value.indexOf(k) >= 0,
get charlist() this.stringlist,
get charlist() { return this.stringlist; },
regexplist: function regexplist(k, default_=null) {
for (let re of this.value)
@@ -494,14 +497,14 @@ var Option = Class("Option", {
return re.result;
return default_;
},
get regexpmap() this.regexplist,
get sitelist() this.regexplist,
get sitemap() this.regexplist
get regexpmap() { return this.regexplist; },
get sitelist() { return this.regexplist; },
get sitemap() { return this.regexplist; }
},
domains: {
sitelist: function (vals) Ary.compact(vals.map(site => util.getHost(site.filter))),
get sitemap() this.sitelist
get sitemap() { return this.sitelist; }
},
stringify: {
@@ -512,9 +515,9 @@ var Option = Class("Option", {
stringmap: function (vals) [Option.quote(k, /:/) + ":" + Option.quote(v, /:/) for ([k, v] of iter(vals))].join(","),
regexplist: function (vals) vals.join(","),
get regexpmap() this.regexplist,
get sitelist() this.regexplist,
get sitemap() this.regexplist
get regexpmap() { return this.regexplist; },
get sitelist() { return this.regexplist; },
get sitemap() { return this.regexplist; }
},
parse: {
@@ -580,7 +583,7 @@ var Option = Class("Option", {
testValues: {
regexpmap: function regexpmap(vals, validator) vals.every(re => validator(re.result)),
get sitemap() this.regexpmap,
get sitemap() { return this.regexpmap; },
stringlist: function stringlist(vals, validator) vals.every(validator, this),
stringmap: function stringmap(vals, validator) values(vals).every(validator, this)
},
@@ -717,11 +720,11 @@ var Option = Class("Option", {
}
return null;
},
get charlist() this.stringlist,
get regexplist() this.stringlist,
get regexpmap() this.stringlist,
get sitelist() this.stringlist,
get sitemap() this.stringlist
get charlist() { return this.stringlist; },
get regexplist() { return this.stringlist; },
get regexpmap() { return this.stringlist; },
get sitelist() { return this.stringlist; },
get sitemap() { return this.stringlist; }
},
validIf: function validIf(test, error) {
@@ -1104,7 +1107,7 @@ var Options = Module("options", {
},
/** @property {Object} The options store. */
get store() storage.options
get store() { return storage.options; }
}, {
}, {
commands: function initCommands(dactyl, modules, window) {

View File

@@ -30,9 +30,9 @@ var Overlay = Class("Overlay", {
cleanups: Class.Memoize(() => []),
objects: Class.Memoize(() => ({})),
get doc() this.window.document,
get doc() { return this.window.document; },
get win() this.window,
get win() { return this.window; },
$: function $(sel, node) DOM(sel, node || this.doc),
@@ -463,9 +463,11 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
};
},
get activeModules() this.activeWindow && this.activeWindow.dactyl.modules,
get activeModules() {
return this.activeWindow && this.activeWindow.dactyl.modules;
},
get modules() [w.dactyl.modules for (w of this.windows)],
get modules() { return [w.dactyl.modules for (w of this.windows)]; },
/**
* The most recently active dactyl window.
@@ -475,7 +477,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
return this.windows.has(win) && win;
},
set activeWindow(win) this._activeWindow = util.weakReference(win),
set activeWindow(win) { this._activeWindow = util.weakReference(win); },
/**
* A list of extant dactyl windows.

View File

@@ -33,9 +33,13 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
this.branches = memoize({
__proto__: this,
get original() this.constructor(this.ORIGINAL + this.root),
get restore() this.constructor(this.RESTORE + this.root),
get saved() this.constructor(this.SAVED + this.root)
get original() {
return this.constructor(this.ORIGINAL + this.root);
},
get restore() {
return this.constructor(this.RESTORE + this.root);
},
get saved() { return this.constructor(this.SAVED + this.root); }
});
if (!defaults)
@@ -90,7 +94,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
/**
* Returns the full name of this object's preference branch.
*/
get root() this.branch.root,
get root() { return this.branch.root; },
/**
* Returns the value of the preference *name*, or *defaultValue* if

View File

@@ -100,8 +100,8 @@ function ProtocolBase() {
};
}
ProtocolBase.prototype = {
get contractID() services.PROTOCOL + this.scheme,
get classDescription() this.scheme + " utility protocol",
get contractID() { return services.PROTOCOL + this.scheme; },
get classDescription() { return this.scheme + " utility protocol"; },
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler]),
purge: function purge() {

View File

@@ -31,10 +31,18 @@ update(Range.prototype, {
contains: function (date) date == null ||
(this.min == null || date >= this.min) && (this.max == null || date <= this.max),
get isEternity() this.max == null && this.min == null,
get isSession() this.max == null && this.min == sanitizer.sessionStart,
get isEternity() {
return this.max == null && this.min == null;
},
get isSession() {
return this.max == null && this.min == sanitizer.sessionStart;
},
get native() this.isEternity ? null : [this.min || 0, this.max == null ? Number.MAX_VALUE : this.max]
get native() {
return this.isEternity ? null
: [this.min || 0, this.max == null ? Number.MAX_VALUE
: this.max];
}
});
var Item = Class("SanitizeItem", {
@@ -49,10 +57,14 @@ var Item = Class("SanitizeItem", {
description: Messages.Localized(""),
get cpdPref() (this.builtin ? "" : Item.PREFIX) + Item.BRANCH + Sanitizer.argToPref(this.name),
get shutdownPref() (this.builtin ? "" : Item.PREFIX) + Item.SHUTDOWN_BRANCH + Sanitizer.argToPref(this.name),
get cpd() prefs.get(this.cpdPref),
get shutdown() prefs.get(this.shutdownPref),
get cpdPref() {
return (this.builtin ? "" : Item.PREFIX) + Item.BRANCH + Sanitizer.argToPref(this.name);
},
get shutdownPref() {
return (this.builtin ? "" : Item.PREFIX) + Item.SHUTDOWN_BRANCH + Sanitizer.argToPref(this.name);
},
get cpd() { return prefs.get(this.cpdPref); },
get shutdown() { return prefs.get(this.shutdownPref); },
shouldSanitize: function (shutdown) (!shutdown || this.builtin || this.persistent) &&
prefs.get(shutdown ? this.shutdownPref : this.pref)
@@ -317,10 +329,18 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
return thing.QueryInterface(Ci.nsILoadContext);
},
get ranAtShutdown() config.prefs.get("didSanitizeOnShutdown"),
set ranAtShutdown(val) config.prefs.set("didSanitizeOnShutdown", Boolean(val)),
get runAtShutdown() prefs.get("privacy.sanitize.sanitizeOnShutdown"),
set runAtShutdown(val) prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val)),
get ranAtShutdown() {
return config.prefs.get("didSanitizeOnShutdown");
},
set ranAtShutdown(val) {
config.prefs.set("didSanitizeOnShutdown", Boolean(val));
},
get runAtShutdown() {
return prefs.get("privacy.sanitize.sanitizeOnShutdown");
},
set runAtShutdown(val) {
prefs.set("privacy.sanitize.sanitizeOnShutdown", Boolean(val));
},
sanitize: function sanitize(items, range)
this.withSavedValues(["sanitizing"], function () {
@@ -607,7 +627,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"The default list of private items to sanitize",
"stringlist", "all",
{
get values() values(sanitizer.itemMap).toArray(),
get values() { return values(sanitizer.itemMap).toArray(); },
completer: function completer(context, extra) {
if (context.filter[0] == "!")
@@ -630,7 +650,11 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"stringlist", "",
{
initialValue: true,
get values() [i for (i of values(sanitizer.itemMap)) if (i.persistent || i.builtin)],
get values() {
return [i
for (i of values(sanitizer.itemMap))
if (i.persistent || i.builtin)];
},
getter: function () !sanitizer.runAtShutdown ? [] : [
item.name for (item of values(sanitizer.itemMap))
if (item.shouldSanitize(true))
@@ -671,7 +695,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
options.add(["cookies", "ck"],
"The default mode for newly added cookie permissions",
"stringlist", "session",
{ get values() Sanitizer.COMMANDS });
{ get values() { return Sanitizer.COMMANDS; }});
options.add(["cookieaccept", "ca"],
"When to accept cookies",

View File

@@ -25,7 +25,7 @@ var StoreBase = Class("StoreBase", {
fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); },
get serial() JSON.stringify(this._object, this.replacer),
get serial() { return JSON.stringify(this._object, this.replacer); },
init: function init(name, store, load, options) {
this._load = load;
@@ -76,7 +76,7 @@ var StoreBase = Class("StoreBase", {
var ArrayStore = Class("ArrayStore", StoreBase, {
_constructor: Array,
get length() this._object.length,
get length() { return this._object.length; },
set: function set(index, value, quiet) {
var orig = this._object[index];
@@ -353,7 +353,7 @@ var Storage = Module("Storage", {
},
_privateMode: false,
get privateMode() this._privateMode,
get privateMode() { return this._privateMode; },
set privateMode(enabled) {
this._privateMode = Boolean(enabled);
@@ -452,7 +452,7 @@ var File = Class("File", {
return file.QueryInterface(Ci.nsILocalFile);
}),
get async() AsyncFile(this),
get async() { return AsyncFile(this); },
charset: Class.Memoize(() => File.defaultEncoding),
@@ -493,15 +493,21 @@ var File = Class("File", {
return this.constructor(newPath, null, this.charset);
},
get fileName() OS.Path.basename(this.path),
get fileName() { return OS.Path.basename(this.path); },
get parent() this.constructor(OS.Path.dirname(this.path), null, this.charset),
get parent() {
return this.constructor(OS.Path.dirname(this.path),
null,
this.charset);
},
/**
* Returns an iterator for all lines in a file.
*/
get lines() File.readLines(services.FileInStream(this.file, -1, 0, 0),
this.charset),
get lines() {
return File.readLines(services.FileInStream(this.file, -1, 0, 0),
this.charset);
},
/**
* Reads this file's entire contents in "text" mode and returns the
@@ -834,7 +840,7 @@ var File = Class("File", {
}
var AsyncFile = Class("AsyncFile", File, {
get async() this,
get async() { return this; },
/*
* Creates a new directory, along with any parent directories which

View File

@@ -40,9 +40,12 @@ update(Sheet.prototype, {
remove: function () { this.hive.remove(this); },
get uri() "dactyl://style/" + this.id + "/" + this.hive.name + "/" + (this.name || ""),
get uri() {
return "dactyl://style/" + this.id + "/" +
this.hive.name + "/" + (this.name || "");
},
get enabled() this._enabled,
get enabled() { return this._enabled; },
set enabled(on) {
if (on != this._enabled || this.fullCSS != this._fullCSS) {
if (on)
@@ -94,7 +97,7 @@ var Hive = Class("Hive", {
this.persist = persist;
},
get modifiable() this.name !== "system",
get modifiable() { return this.name !== "system"; },
addRef: function (obj) {
this.refs.push(util.weakReference(obj));
@@ -118,9 +121,11 @@ var Hive = Class("Hive", {
"@@iterator": function () iter(this.sheets),
get sites() Ary(this.sheets).map(s => s.sites)
.flatten()
.uniq().array,
get sites() {
return Ary(this.sheets).map(s => s.sites)
.flatten()
.uniq().array;
},
/**
* Add a new style sheet.
@@ -503,7 +508,8 @@ var Styles = Module("Styles", {
}),
patterns: memoize({
get property() util.regexp(literal(function () /*
get property() {
return util.regexp(literal(function () /*
(?:
(?P<preSpace> <space>*)
(?P<name> [-a-z]*)
@@ -514,36 +520,43 @@ var Styles = Module("Styles", {
)?
)
(?P<postSpace> <space>* (?: ; | $) )
*/$), "gix", this),
*/$), "gix", this);
},
get function() util.regexp(literal(function () /*
get function() {
return util.regexp(literal(function () /*
(?P<function>
\s* \( \s*
(?: <string> | [^)]* )
\s* (?: \) | $)
)
*/$), "gx", this),
*/$), "gx", this);
},
space: /(?: \s | \/\* .*? \*\/ )/,
get string() util.regexp(literal(function () /*
get string() {
return util.regexp(literal(function () /*
(?P<string>
" (?:[^\\"]|\\.)* (?:"|$) |
' (?:[^\\']|\\.)* (?:'|$)
)
*/$), "gx", this),
*/$), "gx", this);
},
get token() util.regexp(literal(function () /*
(?P<token>
(?P<word> [-\w]+)
<function>?
\s*
| (?P<important> !important\b)
| \s* <string> \s*
| <space>+
| [^;}\s]+
)
*/$), "gix", this)
get token() {
return util.regexp(literal(function () /*
(?P<token>
(?P<word> [-\w]+)
<function>?
\s*
| (?P<important> !important\b)
| \s* <string> \s*
| <space>+
| [^;}\s]+
)
*/$), "gix", this);
}
}),
/**
@@ -713,9 +726,9 @@ var Styles = Module("Styles", {
this.hive = styles.addHive(group.name, this, this.persist);
},
get names() this.hive.names,
get sheets() this.hive.sheets,
get sites() this.hive.sites,
get names() { return this.hive.names; },
get sheets() { return this.hive.sheets; },
get sites() { return this.hive.sites; },
__noSuchMethod__: function __noSuchMethod__(meth, args) {
return apply(this.hive, meth, args);

View File

@@ -30,7 +30,7 @@ var Binding = Class("Binding", {
else
this.removeAttribute("collapsed");
},
get collapsed() !!this.getAttribute("collapsed"),
get collapsed() { return !!this.getAttribute("collapsed"); },
__noSuchMethod__: Class.Property({
configurable: true,
@@ -103,7 +103,10 @@ var Template = Module("Template", {
this.target = params.commandTarget;
},
get command() this.getAttribute("command") || this.getAttribute("key"),
get command() {
return this.getAttribute("command") ||
this.getAttribute("key");
},
events: {
"click": function onClick(event) {

View File

@@ -22,7 +22,7 @@ var Magic = Class("Magic", {
this.str = str;
},
get message() this.str,
get message() { return this.str; },
toString: function () this.str
});
@@ -862,8 +862,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @returns {Object}
*/
intersection: function intersection(r1, r2) ({
get width() this.right - this.left,
get height() this.bottom - this.top,
get width() { return this.right - this.left; },
get height() { return this.bottom - this.top; },
left: Math.max(r1.left, r2.left),
right: Math.min(r1.right, r2.right),
top: Math.max(r1.top, r2.top),