1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-19 23:07:58 +01:00

Add dom.jsm. And stuff.

This commit is contained in:
Kris Maglione
2011-08-22 01:16:14 -04:00
parent 5f1fb91f95
commit fbb6af43ed
39 changed files with 1219 additions and 1191 deletions

24
common/bootstrap.js vendored
View File

@@ -34,11 +34,15 @@ const BOOTSTRAP_JSM = "resource://dactyl/bootstrap.jsm";
const BOOTSTRAP_CONTRACT = "@dactyl.googlecode.com/base/bootstrap";
var JSMLoader = BOOTSTRAP_CONTRACT in Cc && Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader;
var name = "dactyl";
function reportError(e) {
dump("\ndactyl: bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
dump("\n" + name + ": bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n");
Cu.reportError(e);
}
function debug(msg) {
dump(name + ": " + msg + "\n");
}
function httpGet(url) {
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
@@ -86,16 +90,17 @@ function updateVersion() {
}
function startup(data, reason) {
dump("dactyl: bootstrap: startup " + reasonToString(reason) + "\n");
debug("bootstrap: startup " + reasonToString(reason));
basePath = data.installPath;
if (!initialized) {
initialized = true;
dump("dactyl: bootstrap: init" + " " + data.id + "\n");
debug("bootstrap: init" + " " + data.id);
addonData = data;
addon = data;
name = data.id.replace(/@.*/, "");
AddonManager.getAddonByID(addon.id, function (a) {
addon = a;
updateVersion();
@@ -138,12 +143,12 @@ function FactoryProxy(url, classID) {
FactoryProxy.prototype = {
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
register: function () {
dump("dactyl: bootstrap: register: " + this.classID + " " + this.contractID + "\n");
debug("bootstrap: register: " + this.classID + " " + this.contractID);
JSMLoader.registerFactory(this);
},
get module() {
dump("dactyl: bootstrap: create module: " + this.contractID + "\n");
debug("bootstrap: create module: " + this.contractID);
Object.defineProperty(this, "module", { value: {}, enumerable: true });
JSMLoader.load(this.url, this.module);
@@ -156,7 +161,7 @@ FactoryProxy.prototype = {
}
function init() {
dump("dactyl: bootstrap: init\n");
debug("bootstrap: init");
let manifestURI = getURI("chrome.manifest");
let manifest = httpGet(manifestURI.spec)
@@ -227,6 +232,7 @@ function init() {
if (!JSMLoader || JSMLoader.bump !== 6 || Cu.unload)
Cu.import(BOOTSTRAP_JSM, global);
JSMLoader.name = name;
JSMLoader.bootstrap = this;
JSMLoader.load(BOOTSTRAP_JSM, global);
@@ -262,7 +268,7 @@ function init() {
}
function shutdown(data, reason) {
dump("dactyl: bootstrap: shutdown " + reasonToString(reason) + "\n");
debug("bootstrap: shutdown " + reasonToString(reason));
if (reason != APP_SHUTDOWN) {
try {
module("resource://dactyl-content/disable-acr.jsm").cleanup();
@@ -286,7 +292,7 @@ function shutdown(data, reason) {
}
function uninstall(data, reason) {
dump("dactyl: bootstrap: uninstall " + reasonToString(reason) + "\n");
debug("bootstrap: uninstall " + reasonToString(reason));
if (reason == ADDON_UNINSTALL)
Services.prefs.deleteBranch("extensions.dactyl.");
}
@@ -300,6 +306,6 @@ function reasonToString(reason) {
return name;
}
function install(data, reason) { dump("dactyl: bootstrap: install " + reasonToString(reason) + "\n"); }
function install(data, reason) { debug("bootstrap: install " + reasonToString(reason)); }
// vim: set fdm=marker sw=4 ts=4 et:

View File

@@ -10,7 +10,7 @@
var AutoCommand = Struct("event", "filter", "command");
update(AutoCommand.prototype, {
eventName: Class.memoize(function () this.event.toLowerCase()),
eventName: Class.Memoize(function () this.event.toLowerCase()),
match: function (event, pattern) {
return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === String(pattern));

View File

@@ -432,7 +432,7 @@ var Bookmarks = Module("bookmarks", {
return bookmarks.get(args.join(" "), args["-tags"], null, { keyword: context.filter, title: args["-title"] });
},
type: CommandOption.STRING,
validator: function (arg) /^\S+$/.test(arg)
validator: bind("test", /^\S+$/)
};
commands.add(["bma[rk]"],

View File

@@ -1184,8 +1184,8 @@ var Buffer = Module("buffer", {
PageInfo: Struct("PageInfo", "name", "title", "action")
.localize("title"),
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
ZOOM_MIN: Class.Memoize(function () prefs.get("zoom.minPercent")),
ZOOM_MAX: Class.Memoize(function () prefs.get("zoom.maxPercent")),
setZoom: deprecated("buffer.setZoom", function setZoom() buffer.setZoom.apply(buffer, arguments)),
bumpZoomLevel: deprecated("buffer.bumpZoomLevel", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)),

View File

@@ -252,10 +252,10 @@ var CommandWidgets = Class("CommandWidgets", {
[this.commandbar.container, this.statusbar.container].forEach(check);
},
active: Class.memoize(Object),
activeGroup: Class.memoize(Object),
commandbar: Class.memoize(function () ({ group: "Cmd" })),
statusbar: Class.memoize(function () ({ group: "Status" })),
active: Class.Memoize(Object),
activeGroup: Class.Memoize(Object),
commandbar: Class.Memoize(function () ({ group: "Cmd" })),
statusbar: Class.Memoize(function () ({ group: "Status" })),
_ready: function _ready(elem) {
return elem.contentDocument.documentURI === elem.getAttribute("src") &&
@@ -272,9 +272,9 @@ var CommandWidgets = Class("CommandWidgets", {
yield elem;
},
completionContainer: Class.memoize(function () this.completionList.parentNode),
completionContainer: Class.Memoize(function () this.completionList.parentNode),
contextMenu: Class.memoize(function () {
contextMenu: Class.Memoize(function () {
["copy", "copylink", "selectall"].forEach(function (tail) {
// some host apps use "hostPrefixContext-copy" ids
let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]";
@@ -284,15 +284,15 @@ var CommandWidgets = Class("CommandWidgets", {
return document.getElementById("dactyl-contextmenu");
}),
multilineOutput: Class.memoize(function () this._whenReady("dactyl-multiline-output", function (elem) {
multilineOutput: Class.Memoize(function () this._whenReady("dactyl-multiline-output", function (elem) {
elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true);
elem.contentDocument.documentElement.id = "dactyl-multiline-output-top";
elem.contentDocument.body.id = "dactyl-multiline-output-content";
}), true),
multilineInput: Class.memoize(function () document.getElementById("dactyl-multiline-input")),
multilineInput: Class.Memoize(function () document.getElementById("dactyl-multiline-input")),
mowContainer: Class.memoize(function () document.getElementById("dactyl-multiline-output-container"))
mowContainer: Class.Memoize(function () document.getElementById("dactyl-multiline-output-container"))
}, {
getEditor: function getEditor(elem) {
elem.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
@@ -584,7 +584,7 @@ var CommandLine = Module("commandline", {
}, this);
},
widgets: Class.memoize(function () CommandWidgets()),
widgets: Class.Memoize(function () CommandWidgets()),
runSilently: function runSilently(func, self) {
this.withSavedValues(["silent"], function () {

View File

@@ -112,7 +112,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
},
/** @property {string} The name of the current user profile. */
profileName: Class.memoize(function () {
profileName: Class.Memoize(function () {
// NOTE: services.profile.selectedProfile.name doesn't return
// what you might expect. It returns the last _actively_ selected
// profile (i.e. via the Profile Manager or -P option) rather than the
@@ -1221,7 +1221,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, this);
},
stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
urlish: Class.memoize(function () util.regexp(<![CDATA[
urlish: Class.Memoize(function () util.regexp(<![CDATA[
^ (
<domain>+ (:\d+)? (/ .*) |
<domain>+ (:\d+) |

View File

@@ -48,7 +48,7 @@ var ProcessorStack = Class("ProcessorStack", {
this.processors.unshift(KeyProcessor(modes.BASE, hive));
},
passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.modes)),
passUnknown: Class.Memoize(function () options.get("passunknown").getKey(this.modes)),
notify: function () {
events.dbg("NOTIFY()");

View File

@@ -1103,7 +1103,7 @@ var Hints = Module("hints", {
return true;
},
translitTable: Class.memoize(function () {
translitTable: Class.Memoize(function () {
const table = {};
[
[0x00c0, 0x00c6, ["A"]], [0x00c7, 0x00c7, ["C"]],

View File

@@ -60,7 +60,7 @@ var History = Module("history", {
for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry))
obj.push(update(Object.create(item), {
index: obj.length,
icon: Class.memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
icon: Class.Memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
}));
return obj;
},

View File

@@ -45,10 +45,10 @@ var Map = Class("Map", {
}
},
name: Class.memoize(function () this.names[0]),
name: Class.Memoize(function () this.names[0]),
/** @property {[string]} All of this mapping's names (key sequences). */
names: Class.memoize(function () this._keys.map(function (k) events.canonicalKeys(k))),
names: Class.Memoize(function () this._keys.map(function (k) events.canonicalKeys(k))),
get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)],
@@ -293,7 +293,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
delete this.states;
},
states: Class.memoize(function () {
states: Class.Memoize(function () {
var states = {
candidates: {},
mappings: {}
@@ -329,7 +329,7 @@ var Mappings = Module("mappings", {
expandLeader: function expandLeader(keyString) keyString.replace(/<Leader>/i, function () options["mapleader"]),
prefixes: Class.memoize(function () {
prefixes: Class.Memoize(function () {
let list = Array.map("CASM", function (s) s + "-");
return iter(util.range(0, 1 << list.length)).map(function (mask)

View File

@@ -297,9 +297,9 @@ var Marks = Module("marks", {
},
isLocalMark: function isLocalMark(mark) /^[a-z`']$/.test(mark),
isLocalMark: bind("test", /^[a-z`']$/),
isURLMark: function isURLMark(mark) /^[A-Z]$/.test(mark)
isURLMark: bind("test", /^[A-Z]$/)
}, {
events: function () {
let appContent = document.getElementById("appcontent");

View File

@@ -508,12 +508,12 @@ var Modes = Module("modes", {
description: Messages.Localized(""),
displayName: Class.memoize(function () this.name.split("_").map(util.capitalize).join(" ")),
displayName: Class.Memoize(function () this.name.split("_").map(util.capitalize).join(" ")),
isinstance: function isinstance(obj)
this.allBases.indexOf(obj) >= 0 || callable(obj) && this instanceof obj,
allBases: Class.memoize(function () {
allBases: Class.Memoize(function () {
let seen = {}, res = [], queue = [this].concat(this.bases);
for (let mode in array.iterValues(queue))
if (!Set.add(seen, mode)) {
@@ -527,7 +527,7 @@ var Modes = Module("modes", {
get count() !this.insert,
_display: Class.memoize(function _display() this.name.replace("_", " ", "g")),
_display: Class.Memoize(function _display() this.name.replace("_", " ", "g")),
display: function display() this._display,
@@ -535,15 +535,15 @@ var Modes = Module("modes", {
hidden: false,
input: Class.memoize(function input() this.insert || this.bases.length && this.bases.some(function (b) b.input)),
input: Class.Memoize(function input() this.insert || this.bases.length && this.bases.some(function (b) b.input)),
insert: Class.memoize(function insert() this.bases.length && this.bases.some(function (b) b.insert)),
insert: Class.Memoize(function insert() this.bases.length && this.bases.some(function (b) b.insert)),
ownsFocus: Class.memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)),
ownsFocus: Class.Memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)),
passEvent: function passEvent(event) this.input && event.charCode && !(event.ctrlKey || event.altKey || event.metaKey),
passUnknown: Class.memoize(function () options.get("passunknown").getKey(this.name)),
passUnknown: Class.Memoize(function () options.get("passunknown").getKey(this.name)),
get mask() this,

View File

@@ -81,9 +81,9 @@ var MOW = Module("mow", {
__noSuchMethod__: function (meth, args) Buffer[meth].apply(Buffer, [this.body].concat(args)),
get widget() this.widgets.multilineOutput,
widgets: Class.memoize(function widgets() commandline.widgets),
widgets: Class.Memoize(function widgets() commandline.widgets),
body: Class.memoize(function body() this.widget.contentDocument.documentElement),
body: Class.Memoize(function body() this.widget.contentDocument.documentElement),
get document() this.widget.contentDocument,
get window() this.widget.contentWindow,

View File

@@ -99,9 +99,9 @@ var QuickMarks = Module("quickmarks", {
*/
list: function list(filter) {
let marks = [k for ([k, v] in this._qmarks)];
let lowercaseMarks = marks.filter(function (x) /[a-z]/.test(x)).sort();
let uppercaseMarks = marks.filter(function (x) /[A-Z]/.test(x)).sort();
let numberMarks = marks.filter(function (x) /[0-9]/.test(x)).sort();
let lowercaseMarks = marks.filter(bind("test", /[a-z]/)).sort();
let uppercaseMarks = marks.filter(bind("test", /[A-Z]/)).sort();
let numberMarks = marks.filter(bind("test", /[0-9]/)).sort();
marks = Array.concat(lowercaseMarks, uppercaseMarks, numberMarks);

View File

@@ -64,7 +64,7 @@ var Tabs = Module("tabs", {
_mappingCount: 0,
_alternates: Class.memoize(function () [config.tabbrowser.mCurrentTab, null]),
_alternates: Class.Memoize(function () [config.tabbrowser.mCurrentTab, null]),
cleanup: function cleanup() {
for (let [i, tab] in Iterator(this.allTabs)) {

View File

@@ -59,7 +59,6 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
},
onUpdateAvailable: function (addon, install) {
util.dump("onUpdateAvailable");
this.upgrade.push(addon);
install.addListener(this);
install.install();
@@ -278,7 +277,7 @@ var AddonList = Class("AddonList", {
this.update();
},
message: Class.memoize(function () {
message: Class.Memoize(function () {
XML.ignoreWhitespace = true;
util.xmlToDom(<table highlight="Addons" key="list" xmlns={XHTML}>
@@ -348,7 +347,7 @@ var AddonList = Class("AddonList", {
});
var Addons = Module("addons", {
errors: Class.memoize(function ()
errors: Class.Memoize(function ()
array(["ERROR_NETWORK_FAILURE", "ERROR_INCORRECT_HASH",
"ERROR_CORRUPT_FILE", "ERROR_FILE_ACCESS"])
.map(function (e) [AddonManager[e], _("AddonManager." + e)])
@@ -539,7 +538,7 @@ else
return "";
},
installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)),
installLocation: Class.Memoize(function () services.extensionManager.getInstallLocation(this.id)),
getResourceURI: function getResourceURI(path) {
let file = this.installLocation.getItemFile(this.id, path);
return services.io.newFileURI(file);

View File

@@ -6,6 +6,7 @@
var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
Cu.import("resource://dactyl/bootstrap.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
try {
var ctypes;
@@ -14,7 +15,8 @@ try {
catch (e) {}
let objproto = Object.prototype;
let { __lookupGetter__, __lookupSetter__, hasOwnProperty, propertyIsEnumerable } = objproto;
let { __lookupGetter__, __lookupSetter__, __defineGetter__, __defineSetter__,
hasOwnProperty, propertyIsEnumerable } = objproto;
if (typeof XPCSafeJSObjectWrapper === "undefined")
this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
@@ -44,15 +46,15 @@ if (!Object.defineProperty)
}
catch (e if e instanceof TypeError) {}
else {
objproto.__defineGetter__.call(obj, prop, function () value);
__defineGetter__.call(obj, prop, function () value);
if (desc.writable)
objproto.__defineSetter__.call(obj, prop, function (val) { value = val; });
__defineSetter__.call(obj, prop, function (val) { value = val; });
}
if ("get" in desc)
objproto.__defineGetter__.call(obj, prop, desc.get);
__defineGetter__.call(obj, prop, desc.get);
if ("set" in desc)
objproto.__defineSetter__.call(obj, prop, desc.set);
__defineSetter__.call(obj, prop, desc.set);
}
catch (e) {
throw e.stack ? e : Error(e);
@@ -163,9 +165,8 @@ defineModule.dump = function dump_() {
msg = util.objectToString(msg);
return msg;
}).join(", ");
let name = loaded.config ? config.name : "dactyl";
dump(String.replace(msg, /\n?$/, "\n")
.replace(/^./gm, name + ": $&"));
.replace(/^./gm, JSMLoader.name + ": $&"));
}
defineModule.modules = [];
defineModule.time = function time(major, minor, func, self) {
@@ -851,7 +852,7 @@ Class.extend = function extend(subclass, superclass, overrides) {
* property's value.
* @returns {Class.Property}
*/
Class.Memoize = Class.memoize = function Memoize(getter, wait)
Class.Memoize = Class.Memoize = function Memoize(getter, wait)
Class.Property({
configurable: true,
enumerable: true,
@@ -1265,7 +1266,7 @@ var Timer = Class("Timer", {
}
catch (e) {
if (typeof util === "undefined")
dump("dactyl: " + e + "\n" + (e.stack || Error().stack));
dump(JSMLoader.name + ": " + e + "\n" + (e.stack || Error().stack));
else
util.reportError(e);
}

View File

@@ -65,7 +65,7 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
get bookmarks() Class.replaceProperty(this, "bookmarks", this.load()),
keywords: Class.memoize(function () array.toObject([[b.keyword, b] for (b in this) if (b.keyword)])),
keywords: Class.Memoize(function () array.toObject([[b.keyword, b] for (b in this) if (b.keyword)])),
rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"]
.map(function (s) services.bookmarks[s]),

View File

@@ -26,6 +26,8 @@ else
factories: [],
name: "dactyl",
global: this,
globals: JSMLoader ? JSMLoader.globals : {},

View File

@@ -215,7 +215,7 @@ var Command = Class("Command", {
extra: extra
}),
complained: Class.memoize(function () ({})),
complained: Class.Memoize(function () ({})),
/**
* @property {[string]} All of this command's name specs. e.g., "com[mand]"
@@ -286,7 +286,7 @@ var Command = Class("Command", {
*/
options: [],
optionMap: Class.memoize(function () array(this.options)
optionMap: Class.Memoize(function () array(this.options)
.map(function (opt) opt.names.map(function (name) [name, opt]))
.flatten().toObject()),
@@ -297,19 +297,19 @@ var Command = Class("Command", {
return res;
},
argsPrototype: Class.memoize(function argsPrototype() {
argsPrototype: Class.Memoize(function argsPrototype() {
let res = update([], {
__iterator__: function AP__iterator__() array.iterItems(this),
command: this,
explicitOpts: Class.memoize(function () ({})),
explicitOpts: Class.Memoize(function () ({})),
has: function AP_has(opt) Set.has(this.explicitOpts, opt) || typeof opt === "number" && Set.has(this, opt),
get literalArg() this.command.literal != null && this[this.command.literal] || "",
// TODO: string: Class.memoize(function () { ... }),
// TODO: string: Class.Memoize(function () { ... }),
verify: function verify() {
if (this.command.argCount) {
@@ -1175,9 +1175,9 @@ var Commands = Module("commands", {
]]>, /U/g, "\\u"), "x")
}),
validName: Class.memoize(function validName() util.regexp("^" + this.nameRegexp.source + "$")),
validName: Class.Memoize(function validName() util.regexp("^" + this.nameRegexp.source + "$")),
commandRegexp: Class.memoize(function commandRegexp() util.regexp(<![CDATA[
commandRegexp: Class.Memoize(function commandRegexp() util.regexp(<![CDATA[
^
(?P<spec>
(?P<prespace> [:\s]*)
@@ -1514,7 +1514,7 @@ var Commands = Module("commands", {
["+", "One or more arguments are allowed"]],
default: "0",
type: CommandOption.STRING,
validator: function (arg) /^[01*?+]$/.test(arg)
validator: bind("test", /^[01*?+]$/)
},
{
names: ["-nopersist", "-n"],

View File

@@ -405,7 +405,7 @@ var CompletionContext = Class("CompletionContext", {
this.noUpdate = false;
},
ignoreCase: Class.memoize(function () {
ignoreCase: Class.Memoize(function () {
let mode = this.wildcase;
if (mode == "match")
return false;

View File

@@ -10,7 +10,7 @@ let global = this;
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("config", {
exports: ["ConfigBase", "Config", "config"],
require: ["protocol", "services", "storage", "util", "template"],
require: ["dom", "protocol", "services", "storage", "util", "template"],
use: ["io", "messages", "prefs", "styles"]
}, this);
@@ -67,6 +67,7 @@ var ConfigBase = Class("ConfigBase", {
"completion",
"config",
"contexts",
"dom",
"downloads",
"finder",
"help",
@@ -130,7 +131,7 @@ var ConfigBase = Class("ConfigBase", {
elem.style.cssText = this.cssText;
let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
let bg = keys.some(function (k) /^background/.test(k));
let bg = keys.some(bind("test", /^background/));
let fg = keys.indexOf("color") >= 0;
let style = DOM(elem).style;
@@ -141,7 +142,7 @@ var ConfigBase = Class("ConfigBase", {
get addonID() this.name + "@dactyl.googlecode.com",
addon: Class.memoize(function () {
addon: Class.Memoize(function () {
return (JSMLoader.bootstrap || {}).addon ||
require("addons").AddonManager.getAddonByID(this.addonID);
}),
@@ -149,17 +150,17 @@ var ConfigBase = Class("ConfigBase", {
/**
* The current application locale.
*/
appLocale: Class.memoize(function () services.chromeRegistry.getSelectedLocale("global")),
appLocale: Class.Memoize(function () services.chromeRegistry.getSelectedLocale("global")),
/**
* The current dactyl locale.
*/
locale: Class.memoize(function () this.bestLocale(this.locales)),
locale: Class.Memoize(function () this.bestLocale(this.locales)),
/**
* The current application locale.
*/
locales: Class.memoize(function () {
locales: Class.Memoize(function () {
// TODO: Merge with completion.file code.
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
@@ -283,7 +284,7 @@ var ConfigBase = Class("ConfigBase", {
* directory if the application is running from one via an extension
* proxy file.
*/
VCSPath: Class.memoize(function () {
VCSPath: Class.Memoize(function () {
if (/pre$/.test(this.addon.version)) {
let uri = util.newURI(this.addon.getResourceURI("").spec + "../.hg");
if (uri instanceof Ci.nsIFileURL &&
@@ -299,14 +300,14 @@ var ConfigBase = Class("ConfigBase", {
* running from if using an extension proxy file or was built from if
* installed as an XPI.
*/
branch: Class.memoize(function () {
branch: Class.Memoize(function () {
if (this.VCSPath)
return io.system(["hg", "-R", this.VCSPath, "branch"]).output;
return (/pre-hg\d+-(\S*)/.exec(this.version) || [])[1];
}),
/** @property {string} The Dactyl version string. */
version: Class.memoize(function () {
version: Class.Memoize(function () {
if (this.VCSPath)
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
"--template=hg{rev}-{branch}"]).output;
@@ -314,7 +315,7 @@ var ConfigBase = Class("ConfigBase", {
return this.addon.version;
}),
buildDate: Class.memoize(function () {
buildDate: Class.Memoize(function () {
if (this.VCSPath)
return io.system(["hg", "-R", this.VCSPath, "log", "-r.",
"--template={date|isodate}"]).output;
@@ -324,7 +325,7 @@ var ConfigBase = Class("ConfigBase", {
get fileExt() this.name.slice(0, -6),
dtd: Class.memoize(function ()
dtd: Class.Memoize(function ()
iter(this.dtdExtra,
(["dactyl." + k, v] for ([k, v] in iter(config.dtdDactyl))),
(["dactyl." + s, config[s]] for each (s in config.dtdStrings)))
@@ -339,10 +340,10 @@ var ConfigBase = Class("ConfigBase", {
get plugins() "http://dactyl.sf.net/" + this.name + "/plugins",
get faq() this.home + this.name + "/faq",
"list.mailto": Class.memoize(function () config.name + "@googlegroups.com"),
"list.href": Class.memoize(function () "http://groups.google.com/group/" + config.name),
"list.mailto": Class.Memoize(function () config.name + "@googlegroups.com"),
"list.href": Class.Memoize(function () "http://groups.google.com/group/" + config.name),
"hg.latest": Class.memoize(function () this.code + "source/browse/"), // XXX
"hg.latest": Class.Memoize(function () this.code + "source/browse/"), // XXX
"irc": "irc://irc.oftc.net/#pentadactyl",
}),
@@ -397,8 +398,8 @@ var ConfigBase = Class("ConfigBase", {
util.overlayWindow(window, { append: append.elements() });
},
browser: Class.memoize(function () window.gBrowser),
tabbrowser: Class.memoize(function () window.gBrowser),
browser: Class.Memoize(function () window.gBrowser),
tabbrowser: Class.Memoize(function () window.gBrowser),
get browserModes() [modules.modes.NORMAL],
@@ -413,7 +414,7 @@ var ConfigBase = Class("ConfigBase", {
*/
get outputHeight() this.browser.mPanelContainer.boxObject.height,
tabStrip: Class.memoize(function () window.document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer),
tabStrip: Class.Memoize(function () window.document.getElementById("TabsToolbar") || this.tabbrowser.mTabContainer),
}),
/**

View File

@@ -75,7 +75,7 @@ var Group = Class("Group", {
});
},
defaultFilter: Class.memoize(function () this.compileFilter(["*"]))
defaultFilter: Class.Memoize(function () this.compileFilter(["*"]))
});
var Contexts = Module("contexts", {
@@ -283,9 +283,9 @@ var Contexts = Module("contexts", {
return frame;
},
groups: Class.memoize(function () this.matchingGroups()),
groups: Class.Memoize(function () this.matchingGroups()),
allGroups: Class.memoize(function () Object.create(this.groupsProto, {
allGroups: Class.Memoize(function () Object.create(this.groupsProto, {
groups: { value: this.initializedGroups() }
})),
@@ -486,7 +486,7 @@ var Contexts = Module("contexts", {
get persist() this.group.persist,
set persist(val) this.group.persist = val,
prefix: Class.memoize(function () this.name === "builtin" ? "" : this.name + ":"),
prefix: Class.Memoize(function () this.name === "builtin" ? "" : this.name + ":"),
get toStringParams() [this.name]
})

1079
common/modules/dom.jsm Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -74,7 +74,7 @@ var Download = Class("Download", {
get alive() this.inState(["downloading", "notstarted", "paused", "queued", "scanning"]),
allowedCommands: Class.memoize(function () let (self = this) ({
allowedCommands: Class.Memoize(function () let (self = this) ({
get cancel() self.cancelable && self.inState(["downloading", "paused", "starting"]),
get delete() !this.cancel && self.targetFile.exists(),
get launch() self.targetFile.exists() && self.inState(["finished"]),
@@ -213,7 +213,7 @@ var DownloadList = Class("DownloadList",
services.downloadManager.removeListener(this);
},
message: Class.memoize(function () {
message: Class.Memoize(function () {
util.xmlToDom(<table highlight="Downloads" key="list" xmlns={XHTML}>
<tr highlight="DownloadHead">
@@ -280,7 +280,7 @@ var DownloadList = Class("DownloadList",
this.cleanup();
},
allowedCommands: Class.memoize(function () let (self = this) ({
allowedCommands: Class.Memoize(function () let (self = this) ({
get clear() values(self.downloads).some(function (dl) dl.allowedCommands.remove)
})),

View File

@@ -8,7 +8,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("finder", {
exports: ["RangeFind", "RangeFinder", "rangefinder"],
require: ["prefs"],
use: ["messages", "services", "util"]
use: ["dom", "messages", "services", "util"]
}, this);
function equals(a, b) XPCNativeWrapper(a) == XPCNativeWrapper(b);

View File

@@ -7,7 +7,7 @@
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("help", {
exports: ["help"],
require: ["protocol", "services", "util"],
require: ["dom", "protocol", "services", "util"],
use: ["config", "highlight", "messages", "template"]
}, this);
@@ -21,7 +21,8 @@ var Help = Module("Help", {
function Loop(fn)
function (uri, path) {
if (!help.initialized)
return RedirectChannel(uri.spec, uri, 1);
return RedirectChannel(uri.spec, uri, 2,
"Initializing. Please wait...");
return fn.apply(this, arguments);
}

View File

@@ -269,7 +269,7 @@ var IO = Module("io", {
* @property {function} File class.
* @final
*/
File: Class.memoize(function () let (io = this)
File: Class.Memoize(function () let (io = this)
Class("File", File, {
init: function init(path, checkCWD)
init.supercall(this, path, (arguments.length < 2 || checkCWD) && io.cwd)
@@ -826,12 +826,12 @@ unlet s:cpo_save
if (args.bang)
arg = "!" + arg;
// NOTE: Vim doesn't replace ! preceded by 2 or more backslashes and documents it - desirable?
// pass through a raw bang when escaped or substitute the last command
// This is an asinine and irritating feature when we have searchable
// This is an asinine and irritating "feature" when we have searchable
// command-line history. --Kris
if (modules.options["banghist"]) {
// NOTE: Vim doesn't replace ! preceded by 2 or more backslashes and documents it - desirable?
// pass through a raw bang when escaped or substitute the last command
// replaceable bang and no previous command?
dactyl.assert(!/((^|[^\\])(\\\\)*)!/.test(arg) || io._lastRunCommand,
_("command.run.noPrevious"));
@@ -1041,7 +1041,7 @@ unlet s:cpo_save
options.add(["banghist", "bh"],
"Replace occurrences of ! with the previous command when executing external commands",
"boolean", true);
"boolean", false);
options.add(["fileencoding", "fenc"],
"The character encoding used when reading and writing files",

View File

@@ -44,13 +44,13 @@ var JavaScript = Module("javascript", {
}
}),
globals: Class.memoize(function () [
globals: Class.Memoize(function () [
[this.modules.userContext, /*L*/"Global Variables"],
[this.modules, "modules"],
[this.window, "window"]
]),
toplevel: Class.memoize(function () this.modules.jsmodules),
toplevel: Class.Memoize(function () this.modules.jsmodules),
lazyInit: true,
@@ -612,13 +612,13 @@ var JavaScript = Module("javascript", {
return null;
},
magicalNames: Class.memoize(function () Object.getOwnPropertyNames(Cu.Sandbox(this.window), true).sort()),
magicalNames: Class.Memoize(function () Object.getOwnPropertyNames(Cu.Sandbox(this.window), true).sort()),
/**
* A list of properties of the global object which are not
* enumerable by any standard method.
*/
globalNames: Class.memoize(function () let (self = this) array.uniq([
globalNames: Class.Memoize(function () let (self = this) array.uniq([
"Array", "ArrayBuffer", "AttributeName", "Boolean", "Components",
"CSSFontFaceStyleDecl", "CSSGroupRuleRuleList", "CSSNameSpaceRule",
"CSSRGBColor", "CSSRect", "ComputedCSSStyleDeclaration", "Date",
@@ -700,7 +700,7 @@ var JavaScript = Module("javascript", {
modes.addMode("REPL", {
description: "JavaScript Read Eval Print Loop",
bases: [modes.COMMAND_LINE],
displayName: Class.memoize(function () this.name)
displayName: Class.Memoize(function () this.name)
});
},
commandline: function initCommandLine(dactyl, modules, window) {
@@ -746,7 +746,7 @@ var JavaScript = Module("javascript", {
count: 0,
message: Class.memoize(function () {
message: Class.Memoize(function () {
default xml namespace = XHTML;
util.xmlToDom(<div highlight="REPL" key="rootNode"/>,
this.document, this);

View File

@@ -30,7 +30,7 @@ var Messages = Module("messages", {
init: function _(message) {
this.args = arguments;
},
message: Class.memoize(function () {
message: Class.Memoize(function () {
let message = this.args[0];
if (this.args.length > 1) {

View File

@@ -928,7 +928,7 @@ var Options = Module("options", {
setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
cleanupPrefs: Class.memoize(function () localPrefs.Branch("cleanup.option.")),
cleanupPrefs: Class.Memoize(function () localPrefs.Branch("cleanup.option.")),
cleanup: function cleanup(reason) {
if (~["disable", "uninstall"].indexOf(reason))

View File

@@ -539,7 +539,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
/**
* A list of extant dactyl windows.
*/
windows: Class.memoize(function () [])
windows: Class.Memoize(function () [])
});
endModule();

View File

@@ -50,8 +50,9 @@ function NetError(orig, error) {
open: function () { throw error || Cr.NS_ERROR_FILE_NOT_FOUND }
}).data.QueryInterface(Ci.nsIChannel);
}
function RedirectChannel(to, orig, time) {
let html = <html><head><meta http-equiv="Refresh" content={(time || 0) + ";" + to}/></head></html>.toXMLString();
function RedirectChannel(to, orig, time, message) {
let html = <html><head><meta http-equiv="Refresh" content={(time || 0) + ";" + to}/></head>
<body><h2 style="text-align: center">{message || ""}</h2></body></html>.toXMLString();
return StringChannel(html, "text/html", services.io.newURI(to, null, null));
}

View File

@@ -348,7 +348,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
session: 8
},
UNPERMS: Class.memoize(function () iter(this.PERMS).map(Array.reverse).toObject()),
UNPERMS: Class.Memoize(function () iter(this.PERMS).map(Array.reverse).toObject()),
COMMANDS: {
unset: /*L*/"Unset",
@@ -650,7 +650,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
"1d": "Past day",
"1w": "Past week"
},
validator: function (value) /^(a(ll)?|s(ession)|\d+[mhdw])$/.test(value)
validator: bind("test", /^(a(ll)?|s(ession)|\d+[mhdw])$/)
});
options.add(["cookies", "ck"],

View File

@@ -510,13 +510,13 @@ var File = Class("File", {
/**
* @property {string} The current platform's path separator.
*/
PATH_SEP: Class.memoize(function () {
PATH_SEP: Class.Memoize(function () {
let f = services.directory.get("CurProcD", Ci.nsIFile);
f.append("foo");
return f.path.substr(f.parent.path.length, 1);
}),
pathSplit: Class.memoize(function () util.regexp("(?:/|" + util.regexp.escape(this.PATH_SEP) + ")", "g")),
pathSplit: Class.Memoize(function () util.regexp("(?:/|" + util.regexp.escape(this.PATH_SEP) + ")", "g")),
DoesNotExist: function (path, error) ({
path: path,

View File

@@ -8,7 +8,7 @@ Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("styles", {
exports: ["Style", "Styles", "styles"],
require: ["services", "util"],
use: ["contexts", "messages", "template"]
use: ["contexts", "dom", "messages", "template"]
}, this);
function cssUri(css) "chrome-data:text/css," + encodeURI(css);

View File

@@ -57,7 +57,7 @@ var Binding = Class("Binding", {
}
},
events: Class.memoize(function () {
events: Class.Memoize(function () {
let res = [];
for (let obj in this.bindings)
if (Object.getOwnPropertyDescriptor(obj, "events"))
@@ -66,7 +66,7 @@ var Binding = Class("Binding", {
return res;
}),
properties: Class.memoize(function () {
properties: Class.Memoize(function () {
let res = {};
for (let obj in this.bindings)
for (let prop in properties(obj)) {

File diff suppressed because it is too large Load Diff

View File

@@ -83,7 +83,7 @@ var Config = Module("config", ConfigBase, {
dactyl.beep();
},
completers: Class.memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
completers: Class.Memoize(function () update({ mailfolder: "mailFolder" }, this.__proto__.completers)),
dialogs: {
about: ["About Thunderbird",
@@ -143,7 +143,7 @@ var Config = Module("config", ConfigBase, {
},
/*** optional options, there are checked for existence and a fallback provided ***/
features: Class.memoize(function () Set(
features: Class.Memoize(function () Set(
this.isComposeWindow ? ["addressbook"]
: ["hints", "mail", "marks", "addressbook", "tabs"])),