1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-12 07: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

@@ -88,7 +88,7 @@ var Abbreviation = Class("Abbreviation", {
* @property {string} The mode display characters associated with the
* supported mode combination.
*/
get modeChar() Abbreviation.modeChar(this.modes)
get modeChar() { return Abbreviation.modeChar(this.modes); }
}, {
modeChar: function (_modes) {
let result = Ary.uniq(_modes.map(m => m.char)).join("");
@@ -105,7 +105,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
},
/** @property {boolean} True if there are no abbreviations. */
get empty() !values(this._store).find(util.identity),
get empty() { return !values(this._store).find(util.identity); },
/**
* Adds a new abbreviation.
@@ -229,9 +229,9 @@ var Abbreviations = Module("abbreviations", {
*/$), "x", params);
},
get allHives() contexts.allGroups.abbrevs,
get allHives() { return contexts.allGroups.abbrevs; },
get userHives() 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 }),
set: deprecated("group.abbrevs.set", { get: function set() this.user.bound.set }),

View File

@@ -70,7 +70,9 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
* @instance autocommands
*/
var AutoCommands = Module("autocommands", {
get activeHives() contexts.allGroups.autocmd.filter(h => h._store.length),
get activeHives() {
return contexts.allGroups.autocmd.filter(h => h._store.length);
},
add: deprecated("group.autocmd.add", { get: function add() autocommands.user.bound.add }),
get: deprecated("group.autocmd.get", { get: function get() autocommands.user.bound.get }),

View File

@@ -33,12 +33,14 @@ var Bookmarks = Module("bookmarks", {
}
},
get format() ({
anchored: false,
title: ["URL", "Info"],
keys: { text: "url", description: "title", icon: "icon", extra: "extra", tags: "tags", isURI: function () true },
process: [template.icon, template.bookmarkDescription]
}),
get format() {
return {
anchored: false,
title: ["URL", "Info"],
keys: { text: "url", description: "title", icon: "icon", extra: "extra", tags: "tags", isURI: function () true },
process: [template.icon, template.bookmarkDescription]
};
},
// TODO: why is this a filter? --djk
get: function get(filter, tags, maxItems, extra) {

View File

@@ -18,7 +18,7 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
util.addObserver(this);
this._unoverlay = overlay.overlayObject(FullZoom, {
get siteSpecific() false,
get siteSpecific() { return false; },
set siteSpecific(val) {}
});

View File

@@ -324,12 +324,12 @@ var CommandMode = Class("CommandMode", {
this.keepCommand = userContext.hidden_option_command_afterimage;
},
get autocomplete() options["autocomplete"].length,
get autocomplete() { return options["autocomplete"].length; },
get command() this.widgets.command[1],
set command(val) this.widgets.command = val,
get command() { return this.widgets.command[1]; },
set command(val) { this.widgets.command = val; },
get prompt() this._open ? this.widgets.prompt : this._prompt,
get prompt() { return this._open ? this.widgets.prompt : this._prompt; },
set prompt(val) {
if (this._open)
this.widgets.prompt = val;
@@ -362,13 +362,13 @@ var CommandMode = Class("CommandMode", {
this.completions.autocompleteTimer.flush(true);
},
get active() this === commandline.commandSession,
get active() { return this === commandline.commandSession; },
get holdFocus() this.widgets.active.command.inputField,
get holdFocus() { return this.widgets.active.command.inputField; },
get mappingSelf() this,
get mappingSelf() { return this; },
get widgets() commandline.widgets,
get widgets() { return commandline.widgets; },
enter: function CM_enter(stack) {
commandline.commandSession = this;
@@ -453,7 +453,7 @@ var CommandMode = Class("CommandMode", {
var CommandExMode = Class("CommandExMode", CommandMode, {
get mode() modes.EX,
get mode() { return modes.EX; },
historyKey: "command",
@@ -492,7 +492,7 @@ var CommandPromptMode = Class("CommandPromptMode", CommandMode, {
context.forkapply("prompt", 0, this, "completer", args);
},
get mode() modes.PROMPT
get mode() { return modes.PROMPT; }
});
/**
@@ -528,7 +528,7 @@ var CommandLine = Module("commandline", {
return this._messages;
},
get length() this._messages.length,
get length() { return this._messages.length; },
clear: function clear() {
this._messages = [];
@@ -563,7 +563,7 @@ var CommandLine = Module("commandline", {
*
* @returns {boolean}
*/
get commandVisible() !!this.commandSession,
get commandVisible() { return !!this.commandSession; },
/**
* Ensure that the multiline input widget is the correct size.
@@ -591,17 +591,17 @@ var CommandLine = Module("commandline", {
APPEND_TO_MESSAGES : 1 << 3, // Add the string to the message history.
ACTIVE_WINDOW : 1 << 4, // Only echo in active window.
get completionContext() this._completions.context,
get completionContext() { return this._completions.context; },
_silent: false,
get silent() this._silent,
get silent() { return this._silent; },
set silent(val) {
this._silent = val;
this.quiet = this.quiet;
},
_quite: false,
get quiet() this._quiet,
get quiet() { return this._quiet; },
set quiet(val) {
this._quiet = val;
["commandbar", "statusbar"].forEach(function (nodeSet) {
@@ -736,7 +736,7 @@ var CommandLine = Module("commandline", {
},
_hiddenMessages: 0,
get hiddenMessages() this._hiddenMessages,
get hiddenMessages() { return this._hiddenMessages; },
set hiddenMessages(val) {
this._hiddenMessages = val;
if (val)
@@ -917,7 +917,10 @@ var CommandLine = Module("commandline", {
});
},
get commandMode() this.commandSession && isinstance(modes.main, modes.COMMAND_LINE),
get commandMode() {
return this.commandSession &&
isinstance(modes.main, modes.COMMAND_LINE);
},
events: update(
iter(CommandMode.prototype.events).map(
@@ -938,7 +941,7 @@ var CommandLine = Module("commandline", {
}
),
get mowEvents() mow.events,
get mowEvents() { return mow.events; },
/**
* Multiline input events, they will come straight from
@@ -989,7 +992,7 @@ var CommandLine = Module("commandline", {
this.reset();
this.session = session;
},
get store() commandline._store.get(this.mode, []),
get store() { return commandline._store.get(this.mode, []); },
set store(ary) { commandline._store.set(this.mode, ary); },
/**
* Reset the history index to the first entry.
@@ -1165,8 +1168,10 @@ var CommandLine = Module("commandline", {
this.tabTimer.tell(event);
},
get activeContexts() this.context.contextList
.filter(c => c.items.length || c.incomplete),
get activeContexts() {
return this.context.contextList
.filter(c => c.items.length || c.incomplete);
},
/**
* Returns the current completion string relative to the
@@ -1226,7 +1231,7 @@ var CommandLine = Module("commandline", {
+ this.originalValue.substr(this.originalCaret);
},
get selected() this.itemList.selected,
get selected() { return this.itemList.selected; },
set selected(tuple) {
if (!Ary.equals(tuple || [],
this.itemList.selected || []))
@@ -1240,18 +1245,20 @@ var CommandLine = Module("commandline", {
}
},
get caret() this.editor.selection.getRangeAt(0).startOffset,
get caret() {
return this.editor.selection.getRangeAt(0).startOffset;
},
set caret(offset) {
this.editor.selection.collapse(this.editor.rootElement.firstChild, offset);
},
get start() this.context.allItems.start,
get start() { return this.context.allItems.start; },
get items() this.context.allItems.items,
get items() { return this.context.allItems.items; },
get substring() this.context.longestAllSubstring,
get substring() { return this.context.longestAllSubstring; },
get wildtype() this.wildtypes[this.wildIndex] || "",
get wildtype() { return this.wildtypes[this.wildIndex] || ""; },
/**
* Cleanup resources used by this completion session. This
@@ -1726,7 +1733,7 @@ var CommandLine = Module("commandline", {
description: "Active when the command line is focused",
insert: true,
ownsFocus: true,
get mappingSelf() commandline.commandSession
get mappingSelf() { return commandline.commandSession; }
});
// this._extended modes, can include multiple modes, and even main modes
modes.addMode("EX", {
@@ -1961,28 +1968,33 @@ var ItemList = Class("ItemList", {
DOM(this.win).resize(this._onResize.bound.tell);
},
get rootXML()
["div", { highlight: "Normal", style: "white-space: nowrap", key: "root" },
["div", { key: "wrapper" },
["div", { highlight: "Completions", key: "noCompletions" },
["span", { highlight: "Title" },
_("completion.noCompletions")]],
["div", { key: "completions" }]],
get rootXML() {
return ["div", { highlight: "Normal", style: "white-space: nowrap", key: "root" },
["div", { key: "wrapper" },
["div", { highlight: "Completions", key: "noCompletions" },
["span", { highlight: "Title" },
_("completion.noCompletions")]],
["div", { key: "completions" }]],
["div", { highlight: "Completions" },
template.map(util.range(0, options["maxitems"] * 2), i =>
["div", { highlight: "CompItem NonText" },
"~"])]],
["div", { highlight: "Completions" },
template.map(util.range(0, options["maxitems"] * 2), i =>
["div", { highlight: "CompItem NonText" },
"~"])]];
},
get itemCount() this.context.contextList
.reduce((acc, ctxt) => acc + ctxt.items.length, 0),
get itemCount() {
return this.context.contextList
.reduce((acc, ctxt) => acc + ctxt.items.length, 0);
},
get visible() !this.container.collapsed,
set visible(val) this.container.collapsed = !val,
get visible() { return !this.container.collapsed; },
set visible(val) { this.container.collapsed = !val; },
get activeGroups() this.context.contextList
.filter(c => c.items.length || c.message || c.incomplete)
.map(this.getGroup, this),
get activeGroups() {
return this.context.contextList
.filter(c => c.items.length || c.message || c.incomplete)
.map(this.getGroup, this);
},
get selected() {
let g = this.selectedGroup;
@@ -2307,26 +2319,27 @@ var ItemList = Class("ItemList", {
this.range = ItemList.Range(0, 0);
},
get rootXML()
["div", { key: "root", highlight: "CompGroup" },
["div", { highlight: "Completions" },
this.context.createRow(this.context.title || [], "CompTitle")],
["div", { highlight: "CompTitleSep" }],
["div", { key: "contents" },
["div", { key: "up", highlight: "CompLess" }],
["div", { key: "message", highlight: "CompMsg" },
this.context.message || []],
["div", { key: "itemsContainer", class: "completion-items-container" },
["div", { key: "items", highlight: "Completions" }]],
["div", { key: "waiting", highlight: "CompMsg" },
ItemList.WAITING_MESSAGE],
["div", { key: "down", highlight: "CompMore" }]]],
get rootXML() {
return ["div", { key: "root", highlight: "CompGroup" },
["div", { highlight: "Completions" },
this.context.createRow(this.context.title || [], "CompTitle")],
["div", { highlight: "CompTitleSep" }],
["div", { key: "contents" },
["div", { key: "up", highlight: "CompLess" }],
["div", { key: "message", highlight: "CompMsg" },
this.context.message || []],
["div", { key: "itemsContainer", class: "completion-items-container" },
["div", { key: "items", highlight: "Completions" }]],
["div", { key: "waiting", highlight: "CompMsg" },
ItemList.WAITING_MESSAGE],
["div", { key: "down", highlight: "CompMore" }]]];
},
get doc() this.parent.doc,
get win() this.parent.win,
get maxItems() this.parent.maxItems,
get doc() { return this.parent.doc; },
get win() { return this.parent.win; },
get maxItems() { return this.parent.maxItems; },
get itemCount() this.context.items.length,
get itemCount() { return this.context.items.length; },
/**
* Returns a function which will update the scroll offsets
@@ -2440,9 +2453,9 @@ var ItemList = Class("ItemList", {
getOffset: function getOffset(idx) this.offsets.start + (idx || 0),
get selectedRow() this.getRow(this._selectedIdx),
get selectedRow() { return this.getRow(this._selectedIdx); },
get selectedIdx() this._selectedIdx,
get selectedIdx() { return this._selectedIdx; },
set selectedIdx(idx) {
if (this.selectedRow && this._selectedIdx != idx)
DOM(this.selectedRow).attr("selected", null);

View File

@@ -152,7 +152,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
return items;
},
get menuItems() this.getMenuItems(),
get menuItems() { return this.getMenuItems(); },
// Global constants
CURRENT_TAB: "here",
@@ -164,8 +164,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
forcePrivate: null,
forceTarget: null,
get forceOpen() ({ background: this.forceBackground,
target: this.forceTarget }),
get forceOpen() {
return { background: this.forceBackground,
target: this.forceTarget };
},
set forceOpen(val) {
for (let [k, v] of iter({ background: "forceBackground", target: "forceTarget" }))
if (k in val)
@@ -604,8 +606,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
},
/** @property {Element} The currently focused element. */
get focusedElement() services.focus.getFocusedElementForWindow(window, true, {}),
set focusedElement(elem) dactyl.focus(elem),
get focusedElement() {
return services.focus.getFocusedElementForWindow(window, true, {});
},
set focusedElement(elem) { dactyl.focus(elem); },
/**
* Returns whether this Dactyl extension supports *feature*.
@@ -1067,7 +1071,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
pluginFiles: {},
get plugins() plugins,
get plugins() { return plugins; },
setNodeVisible: function setNodeVisible(node, visible) {
if (window.setToolbarVisibility && node.localName == "toolbar")
@@ -1116,7 +1120,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
},
get assert() util.assert,
get assert() { return util.assert; },
/**
* Traps errors in the called function, possibly reporting them.
@@ -1213,7 +1217,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* @property {[Window]} Returns an array of all the host application's
* open windows.
*/
get windows() [w for (w of overlay.windows)]
get windows() { return [w for (w of overlay.windows)]; }
}, {
toolbarHidden: function toolbarHidden(elem) "true" == (elem.getAttribute("autohide") ||

View File

@@ -26,8 +26,14 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
});
},
get registers() storage.newMap("registers", { privateData: true, store: true }),
get registerRing() storage.newArray("register-ring", { privateData: true, store: true }),
get registers() {
return storage.newMap("registers",
{ privateData: true, store: true });
},
get registerRing() {
return storage.newArray("register-ring",
{ privateData: true, store: true });
},
skipSave: false,
@@ -118,10 +124,10 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
}
},
get isCaret() modes.getStack(1).main == modes.CARET,
get isTextEdit() modes.getStack(1).main == modes.TEXT_EDIT,
get isCaret() { return modes.getStack(1).main == modes.CARET; },
get isTextEdit() { return modes.getStack(1).main == modes.TEXT_EDIT; },
get editor() DOM(this.element).editor,
get editor() { return DOM(this.element).editor; },
getController: function getController(cmd) {
let controllers = this.element && this.element.controllers;
@@ -130,8 +136,10 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
return controllers.getControllerForCommand(cmd || "cmd_beginLine");
},
get selection() this.editor && this.editor.selection || null,
get selectionController() this.editor && this.editor.selectionController || null,
get selection() { return this.editor && this.editor.selection || null; },
get selectionController() {
return this.editor && this.editor.selectionController || null;
},
deselect: function () {
if (this.selection && this.selection.focusNode)
@@ -156,9 +164,11 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
this.selection.addRange(range);
},
get selectedText() String(this.selection),
get selectedText() { return String(this.selection); },
get preserveSelection() this.editor && !this.editor.shouldTxnSetSelection,
get preserveSelection() {
return this.editor && !this.editor.shouldTxnSetSelection;
},
set preserveSelection(val) {
if (this.editor)
this.editor.setShouldTxnSetSelection(!val);

View File

@@ -90,7 +90,7 @@ var EventHive = Class("EventHive", Contexts.Hive, {
});
},
get wrapListener() events.bound.wrapListener
get wrapListener() { return events.bound.wrapListener; }
});
/**
@@ -211,7 +211,7 @@ var Events = Module("events", {
}
},
get listen() this.builtin.bound.listen,
get listen() { return this.builtin.bound.listen; },
addSessionListener: deprecated("events.listen", { get: function addSessionListener() this.listen }),
/**
@@ -248,7 +248,7 @@ var Events = Module("events", {
* @param {string} macro The name for the macro.
*/
_recording: null,
get recording() this._recording,
get recording() { return this._recording; },
set recording(macro) {
dactyl.assert(macro == null || /[a-zA-Z0-9]/.test(macro),
@@ -437,7 +437,11 @@ var Events = Module("events", {
return apply(DOM.Event, "stringify", arguments);
},
get defaultTarget() dactyl.focusedElement || content.document.body || document.documentElement,
get defaultTarget() {
return dactyl.focusedElement ||
content.document.body ||
document.documentElement;
},
/**
* Returns true if there's a known native key handler for the given
@@ -1097,7 +1101,7 @@ var Events = Module("events", {
events._macroKeys.pop();
events.recording = arg;
},
{ get arg() !modes.recording });
{ get arg() { return !modes.recording; }});
mappings.add([modes.COMMAND],
["@", "<play-macro>"], "Play a macro",
@@ -1140,7 +1144,7 @@ var Events = Module("events", {
}
},
get active() this.stack.length,
get active() { return this.stack.length; },
get: function get(mode, key) this.stack.mappings[key],
@@ -1158,7 +1162,7 @@ var Events = Module("events", {
has: function (key) this.pass.has(key) || hasOwnProperty(this.commandHive.stack.mappings, key),
get pass() (this.flush(), this.pass),
get pass() { this.flush(); return this.pass; },
parse: function parse() {
let value = parse.superapply(this, arguments);

View File

@@ -10,7 +10,7 @@
/** @instance hints */
var HintSession = Class("HintSession", CommandMode, {
get extendedMode() modes.HINTS,
get extendedMode() { return modes.HINTS; },
init: function init(mode, opts={}) {
init.supercall(this);
@@ -54,13 +54,16 @@ var HintSession = Class("HintSession", CommandMode, {
this.checkUnique();
},
get docs() this._docs = this._docs.filter(({ doc }) => !Cu.isDeadWrapper(doc)),
get docs() {
return this._docs = this._docs.filter(({ doc }) =>
!Cu.isDeadWrapper(doc));
},
set docs(docs) {
this._docs = docs;
},
Hint: {
get active() this._active,
get active() { return this._active; },
set active(val) {
this._active = val;
if (val)
@@ -73,7 +76,7 @@ var HintSession = Class("HintSession", CommandMode, {
hints.setClass(this.imgSpan, this.valid ? val : null);
},
get ambiguous() this.span.hasAttribute("ambiguous"),
get ambiguous() { return this.span.hasAttribute("ambiguous"); },
set ambiguous(val) {
let meth = val ? "setAttribute" : "removeAttribute";
this.elem[meth]("ambiguous", "true");
@@ -82,7 +85,7 @@ var HintSession = Class("HintSession", CommandMode, {
this.imgSpan[meth]("ambiguous", "true");
},
get valid() this._valid,
get valid() { return this._valid; },
set valid(val) {
this._valid = val,
@@ -93,9 +96,9 @@ var HintSession = Class("HintSession", CommandMode, {
}
},
get mode() modes.HINTS,
get mode() { return modes.HINTS; },
get prompt() ["Question", UTF8(this.hintMode.prompt) + ": "],
get prompt() { return ["Question", UTF8(this.hintMode.prompt) + ": "]; },
leave: function leave(stack) {
leave.superapply(this, arguments);
@@ -142,7 +145,7 @@ var HintSession = Class("HintSession", CommandMode, {
},
_escapeNumbers: false,
get escapeNumbers() this._escapeNumbers,
get escapeNumbers() { return this._escapeNumbers; },
set escapeNumbers(val) {
this.clearTimeout();
this._escapeNumbers = !!val;

View File

@@ -9,9 +9,9 @@
var History = Module("history", {
SORT_DEFAULT: "-date",
get format() bookmarks.format,
get format() { return bookmarks.format; },
get service() services.history,
get service() { return services.history; },
get: function get(filter, maxItems, sort=this.SORT_DEFAULT) {
if (isString(filter))
@@ -310,7 +310,7 @@ var History = Module("history", {
jumps = jumps.locations.map(l => ({
__proto__: l,
title: buffer.title,
get URI() util.newURI(this.location)
get URI() { return util.newURI(this.location); }
}));
}

View File

@@ -224,11 +224,14 @@ var KeyProcessor = Class("KeyProcessor", {
this.wantCount = this.main.count;
},
get toStringParams() [this.main.name, this.hive.name],
get toStringParams() { return [this.main.name, this.hive.name]; },
countStr: "",
command: "",
get count() this.countStr ? Number(this.countStr) : this.main.params.count || null,
get count() {
return this.countStr ? Number(this.countStr)
: this.main.params.count || null;
},
append: function append(event) {
this.events.push(event);

View File

@@ -50,10 +50,15 @@ var Map = Class("Map", {
/** @property {[string]} All of this mapping's names (key sequences). */
names: Class.Memoize(function () this._keys.map(k => DOM.Event.canonicalKeys(k))),
get toStringParams() [this.modes.map(m => m.name),
this.names.map(JSON.stringify)],
get toStringParams() {
return [this.modes.map(m => m.name),
this.names.map(JSON.stringify)];
},
get identifier() [this.modes[0].name, this.hive.prefix + this.names[0]].join("."),
get identifier() {
return [this.modes[0].name, this.hive.prefix + this.names[0]]
.join(".");
},
/** @property {number} A unique ID for this mapping. */
id: null,
@@ -107,7 +112,7 @@ var Map = Class("Map", {
*/
hasName: function (name) this.keys.indexOf(name) >= 0,
get keys() Ary.flatten(this.names.map(mappings.bound.expand)),
get keys() { return Ary.flatten(this.names.map(mappings.bound.expand)); },
/**
* Execute the action for this mapping.
@@ -286,8 +291,8 @@ var MapHive = Class("MapHive", Contexts.Hive, {
"@@iterator": function () Ary.iterValues(this),
get candidates() this.states.candidates,
get mappings() this.states.mappings,
get candidates() { return this.states.candidates; },
get mappings() { return this.states.mappings; },
add: function (map) {
this.push(map);
@@ -349,9 +354,9 @@ var Mappings = Module("mappings", {
repeat: Modes.boundProperty(),
get allHives() contexts.allGroups.mappings,
get allHives() { return contexts.allGroups.mappings; },
get userHives() 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),
@@ -557,7 +562,7 @@ var Mappings = Module("mappings", {
count: args["-count"] || !(args["-ex"] || args["-javascript"]),
noremap: args["-builtin"],
persist: !args["-nopersist"],
get rhs() String(this.action),
get rhs() { return String(this.action); },
silent: args["-silent"]
});
}

View File

@@ -28,12 +28,16 @@ var Marks = Module("marks", {
* @property {Array} Returns all marks, both local and URL, in a sorted
* array.
*/
get all() iter(this._localMarks.get(this.localURI) || {},
this._urlMarks
).sort((a, b) => String.localeCompare(a[0], b[0]))
.toArray(),
get all() {
return iter(this._localMarks.get(this.localURI) || {},
this._urlMarks
).sort((a, b) => String.localeCompare(a[0], b[0]))
.toArray();
},
get localURI() buffer.focusedFrame.document.documentURI.replace(/#.*/, ""),
get localURI() {
return buffer.focusedFrame.document.documentURI.replace(/#.*/, "");
},
Mark: function Mark(params={}) {
let win = buffer.focusedFrame;

View File

@@ -57,8 +57,12 @@ var Modes = Module("modes", {
bases: [this.NORMAL]
}, {
get pref() prefs.get("accessibility.browsewithcaret"),
set pref(val) prefs.set("accessibility.browsewithcaret", val),
get pref() {
return prefs.get("accessibility.browsewithcaret");
},
set pref(val) {
prefs.set("accessibility.browsewithcaret", val);
},
enter: function (stack) {
if (stack.pop && !this.pref)
@@ -196,17 +200,22 @@ var Modes = Module("modes", {
"@@iterator": function __iterator__() Ary.iterValues(this.all),
get all() this._modes.slice(),
get all() { return this._modes.slice(); },
get mainModes() (mode
for ([k, mode] of iter(modes._modeMap))
if (!mode.extended && mode.name == k)),
get mainModes() {
return (mode
for ([k, mode] of iter(modes._modeMap))
if (!mode.extended && mode.name == k));
},
get mainMode() this._modeMap[this._main],
get mainMode() { return this._modeMap[this._main]; },
get passThrough() !!(this.main & (this.PASS_THROUGH|this.QUOTE)) ^ (this.getStack(1).main === this.PASS_THROUGH),
get passThrough() {
return !!(this.main & (this.PASS_THROUGH|this.QUOTE)) ^
(this.getStack(1).main === this.PASS_THROUGH);
},
get topOfStack() this._modeStack[this._modeStack.length - 1],
get topOfStack() { return this._modeStack[this._modeStack.length - 1]; },
addMode: function addMode(name, options, params) {
let mode = Modes.Mode(name, options, params);
@@ -246,7 +255,7 @@ var Modes = Module("modes", {
getStack: function getStack(idx) this._modeStack[this._modeStack.length - idx - 1] || this._modeStack[0],
get stack() this._modeStack.slice(),
get stack() { return this._modeStack.slice(); },
getCharModes: function getCharModes(chr) (this.modeChars[chr] || []).slice(),
@@ -410,16 +419,16 @@ var Modes = Module("modes", {
this.pop();
},
get recording() this._recording,
get recording() { return this._recording; },
set recording(value) { this._recording = value; this.show(); },
get replaying() this._replaying,
get replaying() { return this._replaying; },
set replaying(value) { this._replaying = value; this.show(); },
get main() this._main,
get main() { return this._main; },
set main(value) { this.set(value); },
get extended() this._extended,
get extended() { return this._extended; },
set extended(value) { this.set(null, value); }
}, {
Mode: Class("Mode", {
@@ -455,9 +464,9 @@ var Modes = Module("modes", {
return res;
}),
get bases() this.input ? [modes.INPUT] : [modes.MAIN],
get bases() { return this.input ? [modes.INPUT] : [modes.MAIN]; },
get count() !this.insert,
get count() { return !this.insert; },
_display: Class.Memoize(function _display() this.name.replace(/_/g, " ")),
@@ -477,9 +486,9 @@ var Modes = Module("modes", {
passUnknown: Class.Memoize(function () options.get("passunknown").getKey(this.name)),
get mask() this,
get mask() { return this; },
get toStringParams() [this.name],
get toStringParams() { return [this.name]; },
valueOf: function valueOf() this.id
}, {
@@ -499,13 +508,15 @@ var Modes = Module("modes", {
StackElement.defaultValue("params", function () this.main.params);
update(StackElement.prototype, {
get toStringParams() !loaded.has("modes") ? [this.main.name] : [
this.main.name,
["(", modes.all.filter(m => this.extended & m)
.map(m => m.name)
.join("|"),
")"].join("")
]
get toStringParams() {
return !loaded.has("modes") ? [this.main.name] : [
this.main.name,
["(", modes.all.filter(m => this.extended & m)
.map(m => m.name)
.join("|"),
")"].join("")
];
}
});
return StackElement;
})(),
@@ -633,8 +644,10 @@ var Modes = Module("modes", {
validator: function validator(vals) vals.map(v => v.replace(/^!/, ""))
.every(k => hasOwnProperty(this.values, k)),
get values() Ary.toObject([[m.name.toLowerCase(), m.description]
for (m of modes._modes) if (!m.hidden)])
get values() {
return Ary.toObject([[m.name.toLowerCase(), m.description]
for (m of modes._modes) if (!m.hidden)]);
}
};
options.add(["passunknown", "pu"],

View File

@@ -68,13 +68,13 @@ var MOW = Module("mow", {
__noSuchMethod__: function (meth, args) apply(Buffer, meth, [this.body].concat(args)),
get widget() this.widgets.multilineOutput,
get widget() { return this.widgets.multilineOutput; },
widgets: Class.Memoize(function widgets() commandline.widgets),
body: Class.Memoize(function body() this.widget.contentDocument.documentElement),
get document() this.widget.contentDocument,
get window() this.widget.contentWindow,
get document() { return this.widget.contentDocument; },
get window() { return this.widget.contentWindow; },
/**
* Display a multi-line message.

View File

@@ -110,7 +110,9 @@ var StatusLine = Module("statusline", {
})(prepend);
overlay.overlayWindow(window, {
objects: this.widgets = { get status() this.container },
objects: this.widgets = {
get status() { return this.container; }
},
prepend: prepend
});
@@ -125,7 +127,9 @@ var StatusLine = Module("statusline", {
CustomizableUI.unregisterArea(this.statusBar.id, false);
},
get visible() !this.statusBar.collapsed && !this.statusBar.hidden,
get visible() {
return !this.statusBar.collapsed && !this.statusBar.hidden;
},
signals: {
"browser.locationChange": function (webProgress, request, uri) {
@@ -223,7 +227,7 @@ var StatusLine = Module("statusline", {
highlight.highlightNode(this.statusBar, this.baseGroup + highlightGroup[type]);
},
get security() this._security,
get security() { return this._security; },
// update all fields of the statusline
update: function update() {
@@ -246,7 +250,7 @@ var StatusLine = Module("statusline", {
*
* @param {string} url The URL to display.
*/
get status() this._uri,
get status() { return this._uri; },
set status(uri) {
let modified = "";
let url = uri;
@@ -285,7 +289,7 @@ var StatusLine = Module("statusline", {
this._status = uri;
},
get bookmarked() this._bookmarked,
get bookmarked() { return this._bookmarked; },
set bookmarked(val) {
this._bookmarked = val;
if (this.status)
@@ -309,8 +313,10 @@ var StatusLine = Module("statusline", {
* @param {string} buffer
* @optional
*/
get inputBuffer() this.widgets.inputbuffer.value,
set inputBuffer(val) this.widgets.inputbuffer.value = val == null ? "" : val,
get inputBuffer() { return this.widgets.inputbuffer.value; },
set inputBuffer(val) {
this.widgets.inputbuffer.value = val == null ? "" : val;
},
updateInputBuffer: deprecated("statusline.inputBuffer", function updateInputBuffer(val) { this.inputBuffer = val; }),
/**

View File

@@ -88,7 +88,9 @@ var Tabs = Module("tabs", {
document).appendTo(img.parentNode);
update(tab, {
get dactylOrdinal() Number(dom.nodes.icon.value),
get dactylOrdinal() {
return Number(dom.nodes.icon.value);
},
set dactylOrdinal(i) {
dom.nodes.icon.value = dom.nodes.label.textContent = i;
this.setAttribute("dactylOrdinal", i);
@@ -109,13 +111,18 @@ var Tabs = Module("tabs", {
this.updateSelectionHistory();
},
get allTabs() Array.slice(config.tabbrowser.tabContainer.childNodes),
get allTabs() {
return Array.slice(config.tabbrowser.tabContainer.childNodes);
},
/**
* @property {Object} The previously accessed tab or null if no tab
* other than the current one has been accessed.
*/
get alternate() this.allTabs.indexOf(this._alternates[1]) > -1 ? this._alternates[1] : null,
get alternate() {
let alt = this._alternates[1];
return this.allTabs.indexOf(alt) > -1 ? alt : null;
},
/**
* @property {Iterator(Object)} A genenerator that returns all browsers
@@ -131,14 +138,17 @@ var Tabs = Module("tabs", {
/**
* @property {number} The number of tabs in the current window.
*/
get count() config.tabbrowser.mTabs.length,
get count() { return config.tabbrowser.mTabs.length; },
/**
* @property {Object} The local options store for the current tab.
*/
get options() this.localStore.options,
get options() { return this.localStore.options; },
get visibleTabs() config.tabbrowser.visibleTabs || this.allTabs.filter(tab => !tab.hidden),
get visibleTabs() {
return config.tabbrowser.visibleTabs ||
this.allTabs.filter(tab => !tab.hidden);
},
/**
* Returns the local state store for the tab at the specified *tabIndex*.
@@ -163,18 +173,20 @@ var Tabs = Module("tabs", {
* @property {Object} The local state store for the currently selected
* tab.
*/
get localStore() this.getLocalStore(),
get localStore() { return this.getLocalStore(); },
localStorePrototype: memoize({
instance: {},
get options() ({})
get options() { return {}; }
}),
/**
* @property {[Object]} The array of closed tabs for the current
* session.
*/
get closedTabs() JSON.parse(services.sessionStore.getClosedTabData(window)),
get closedTabs() {
return JSON.parse(services.sessionStore.getClosedTabData(window));
},
/**
* Clones the specified *tab* and append it to the tab list.