mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-05 11:14:11 +01:00
Make Teledactyl minimally functional, albeit with quite a lot of errors on the console.
This commit is contained in:
@@ -465,7 +465,7 @@ var Addons = Module("addons", {
|
||||
}
|
||||
});
|
||||
|
||||
if (!("nsIExtensionManager" in Ci) || !services.extensionManager)
|
||||
if (!services.has("extensionManager"))
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
else
|
||||
var AddonManager = {
|
||||
|
||||
@@ -873,7 +873,7 @@ Class.prototype = {
|
||||
return services.Timer(timeout_notify, timeout || 0, services.Timer.TYPE_ONE_SHOT);
|
||||
}
|
||||
};
|
||||
memoize(Class.prototype, "closure", function closure() {
|
||||
Class.makeClosure = function makeClosure() {
|
||||
const self = this;
|
||||
function closure(fn) function _closure() {
|
||||
try {
|
||||
@@ -896,7 +896,8 @@ memoize(Class.prototype, "closure", function closure() {
|
||||
});
|
||||
}, this);
|
||||
return closure;
|
||||
});
|
||||
};
|
||||
memoize(Class.prototype, "closure", Class.makeClosure);
|
||||
|
||||
/**
|
||||
* A base class generator for classes which implement XPCOM interfaces.
|
||||
|
||||
@@ -151,6 +151,8 @@ var ConfigBase = Class("ConfigBase", {
|
||||
return version;
|
||||
}),
|
||||
|
||||
get fileExt() this.name.slice(0, -5),
|
||||
|
||||
dtd: memoize({
|
||||
get name() config.name,
|
||||
get home() "http://dactyl.sourceforge.net/",
|
||||
@@ -243,8 +245,6 @@ var ConfigBase = Class("ConfigBase", {
|
||||
*/
|
||||
autocommands: {},
|
||||
|
||||
commandContainer: "browser-bottombox",
|
||||
|
||||
/**
|
||||
* @property {Object} A map of :command-complete option values to completer
|
||||
* function names.
|
||||
@@ -350,6 +350,8 @@ var ConfigBase = Class("ConfigBase", {
|
||||
*/
|
||||
scripts: [],
|
||||
|
||||
sidebars: {},
|
||||
|
||||
/**
|
||||
* @property {string} The leaf name of any temp files created by
|
||||
* {@link io.createTempFile}.
|
||||
|
||||
@@ -166,8 +166,10 @@ var RangeFinder = Module("rangefinder", {
|
||||
}
|
||||
}, {
|
||||
}, {
|
||||
modes: function (dactyl, modules, window) {
|
||||
modes: function initModes(dactyl, modules, window) {
|
||||
const { modes } = modules;
|
||||
initModes.superapply("commandline", arguments);
|
||||
|
||||
modes.addMode("FIND", {
|
||||
description: "Find mode, active when typing search input",
|
||||
bases: [modes.COMMAND_LINE],
|
||||
@@ -181,14 +183,14 @@ var RangeFinder = Module("rangefinder", {
|
||||
bases: [modes.FIND]
|
||||
});
|
||||
},
|
||||
commands: function (dactyl, modules, window) {
|
||||
commands: function initCommands(dactyl, modules, window) {
|
||||
const { commands, rangefinder } = modules;
|
||||
commands.add(["noh[lfind]"],
|
||||
"Remove the find highlighting",
|
||||
function () { rangefinder.clear(); },
|
||||
{ argCount: "0" });
|
||||
},
|
||||
commandline: function (dactyl, modules, window) {
|
||||
commandline: function initCommandline(dactyl, modules, window) {
|
||||
const { rangefinder } = modules;
|
||||
rangefinder.CommandMode = Class("CommandFindMode", modules.CommandMode, {
|
||||
init: function init(mode) {
|
||||
|
||||
@@ -69,7 +69,10 @@ var Option = Class("Option", {
|
||||
if (extraInfo)
|
||||
update(this, extraInfo);
|
||||
|
||||
if (arguments.length > 3) {
|
||||
if (set.has(this.modules.config.defaults, this.name))
|
||||
defaultValue = this.modules.config.defaults[this.name];
|
||||
|
||||
if (defaultValue !== undefined) {
|
||||
if (this.type == "string")
|
||||
defaultValue = Commands.quote(defaultValue);
|
||||
|
||||
|
||||
@@ -27,13 +27,13 @@ var ModuleBase = Class("ModuleBase", {
|
||||
});
|
||||
|
||||
var Overlay = Module("Overlay", {
|
||||
init: function () {
|
||||
init: function init() {
|
||||
services["dactyl:"]; // Hack. Force module initialization.
|
||||
|
||||
config.loadStyles();
|
||||
|
||||
util.overlayWindow(config.overlayChrome, function (window) ({
|
||||
init: function (document) {
|
||||
util.overlayWindow(config.overlayChrome, function overlay(window) ({
|
||||
init: function onInit(document) {
|
||||
/**
|
||||
* @constructor Module
|
||||
*
|
||||
@@ -187,48 +187,20 @@ var Overlay = Module("Overlay", {
|
||||
"mow",
|
||||
"statusline"
|
||||
].forEach(function (name) defineModule.time("load", name, modules.load, modules, name));
|
||||
|
||||
config.scripts.forEach(modules.load);
|
||||
}, this);
|
||||
},
|
||||
load: function (document) {
|
||||
load: function onLoad(document) {
|
||||
// This is getting to be horrible. --Kris
|
||||
|
||||
var { modules, Module } = window.dactyl.modules;
|
||||
delete window.dactyl;
|
||||
|
||||
Module.list.forEach(function (module) {
|
||||
modules.__defineGetter__(module.className, function () {
|
||||
delete modules[module.className];
|
||||
return load(module.className, null, Components.stack.caller);
|
||||
});
|
||||
});
|
||||
|
||||
const start = Date.now();
|
||||
const deferredInit = { load: [] };
|
||||
const deferredInit = { load: {} };
|
||||
const seen = set();
|
||||
const loaded = set();
|
||||
modules.loaded = loaded;
|
||||
|
||||
function init(module) {
|
||||
let name = module.constructor.className;
|
||||
|
||||
function init(func, mod)
|
||||
function () defineModule.time(module.className || module.constructor.className, mod,
|
||||
func, modules[name],
|
||||
modules.dactyl, modules, window);
|
||||
|
||||
set.add(loaded, name);
|
||||
for (let [mod, func] in Iterator(module.INIT)) {
|
||||
if (mod in loaded)
|
||||
init(func, mod)();
|
||||
else {
|
||||
deferredInit[mod] = deferredInit[mod] || [];
|
||||
deferredInit[mod].push(init(func, mod));
|
||||
}
|
||||
}
|
||||
for (let [, fn] in iter(deferredInit[module.constructor.className] || []))
|
||||
fn();
|
||||
}
|
||||
|
||||
function load(module, prereq, frame) {
|
||||
if (isString(module)) {
|
||||
if (!Module.constructors.hasOwnProperty(module))
|
||||
@@ -255,8 +227,6 @@ var Overlay = Module("Overlay", {
|
||||
loaded[module.className] = true;
|
||||
|
||||
frob(module.className);
|
||||
|
||||
// init(modules[module.className]);
|
||||
}
|
||||
catch (e) {
|
||||
util.dump("Loading " + (module && module.className) + ":");
|
||||
@@ -265,36 +235,48 @@ var Overlay = Module("Overlay", {
|
||||
return modules[module.className];
|
||||
}
|
||||
|
||||
Module.list.forEach(function (mod) {
|
||||
Object.keys(mod.prototype.INIT).forEach(function (name) {
|
||||
deferredInit[name] = deferredInit[name] || [];
|
||||
deferredInit[name].push(function () {
|
||||
// util.dump("INIT: " + mod.className + ":" + name);
|
||||
defineModule.time(mod.className, name,
|
||||
name, mod.prototype.INIT,
|
||||
function deferInit(name, INIT, mod) {
|
||||
let init = deferredInit[name] = deferredInit[name] || {};
|
||||
let className = mod.className || mod.constructor.className;
|
||||
|
||||
init[className] = function callee() {
|
||||
if (!callee.frobbed)
|
||||
defineModule.time(className, name, INIT[name], mod,
|
||||
modules.dactyl, modules, window);
|
||||
});
|
||||
callee.frobbed = true;
|
||||
};
|
||||
|
||||
if (name !== "init" && name !== "load")
|
||||
INIT[name].superapply = function (name) { init[name](); };
|
||||
}
|
||||
|
||||
function frobModules() {
|
||||
Module.list.forEach(function frobModule(mod) {
|
||||
if (!mod.frobbed) {
|
||||
modules.__defineGetter__(mod.className, function () {
|
||||
delete modules[mod.className];
|
||||
return load(mod.className, null, Components.stack.caller);
|
||||
});
|
||||
Object.keys(mod.prototype.INIT).forEach(function (name) { deferInit(name, mod.prototype.INIT, mod); });
|
||||
}
|
||||
mod.frobbed = true;
|
||||
});
|
||||
});
|
||||
defineModule.modules.forEach(function (mod) {
|
||||
}
|
||||
defineModule.modules.forEach(function defModule(mod) {
|
||||
let names = set(Object.keys(mod.INIT));
|
||||
if ("init" in mod.INIT)
|
||||
set.add(names, "init");
|
||||
|
||||
keys(names).forEach(function (name) {
|
||||
deferredInit[name] = deferredInit[name] || [];
|
||||
deferredInit[name].push(function () {
|
||||
// util.dump("INIT: " + mod.constructor.className + ":" + name);
|
||||
defineModule.time(mod.constructor.className, name,
|
||||
mod.INIT[name], mod,
|
||||
modules.dactyl, modules, window);
|
||||
});
|
||||
});
|
||||
keys(names).forEach(function (name) { deferInit(name, mod.INIT, mod); });
|
||||
});
|
||||
|
||||
function frob(name) { (deferredInit[name] || []).forEach(call); }
|
||||
function frob(name) { values(deferredInit[name] || {}).forEach(call); }
|
||||
|
||||
frobModules();
|
||||
frob("init");
|
||||
modules.config.scripts.forEach(modules.load);
|
||||
frobModules();
|
||||
|
||||
defineModule.modules.forEach(function ({ lazyInit, constructor: { className } }) {
|
||||
if (!lazyInit) {
|
||||
frob(className);
|
||||
@@ -316,10 +298,13 @@ var Overlay = Module("Overlay", {
|
||||
|
||||
modules.events.listen(window, "unload", function onUnload() {
|
||||
window.removeEventListener("unload", onUnload.wrapped, false);
|
||||
|
||||
for (let prop in properties(modules)) {
|
||||
let mod = Object.getOwnPropertyDescriptor(modules, prop).value;
|
||||
|
||||
if (mod instanceof ModuleBase || mod && mod.isLocalModule) {
|
||||
mod.stale = true;
|
||||
|
||||
if ("destroy" in mod)
|
||||
util.trapErrors("destroy", mod);
|
||||
}
|
||||
|
||||
@@ -114,13 +114,14 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
},
|
||||
override: true
|
||||
});
|
||||
this.addItem("host", {
|
||||
description: "All data from the given host",
|
||||
action: function (range, host) {
|
||||
if (host)
|
||||
services.privateBrowsing.removeDataFromDomain(host);
|
||||
}
|
||||
});
|
||||
if (services.has("privateBrowsing"))
|
||||
this.addItem("host", {
|
||||
description: "All data from the given host",
|
||||
action: function (range, host) {
|
||||
if (host)
|
||||
services.privateBrowsing.removeDataFromDomain(host);
|
||||
}
|
||||
});
|
||||
this.addItem("sitesettings", {
|
||||
builtin: true,
|
||||
description: "Site preferences",
|
||||
@@ -547,7 +548,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
},
|
||||
options: function (dactyl, modules) {
|
||||
const options = modules.options;
|
||||
if (services.privateBrowsing)
|
||||
if (services.has("privateBrowsing"))
|
||||
options.add(["private", "pornmode"],
|
||||
"Set the 'private browsing' option",
|
||||
"boolean", false,
|
||||
|
||||
@@ -18,7 +18,6 @@ defineModule("services", {
|
||||
*/
|
||||
var Services = Module("Services", {
|
||||
init: function () {
|
||||
this.classes = {};
|
||||
this.services = {};
|
||||
|
||||
this.add("annotation", "@mozilla.org/browser/annotation-service;1", Ci.nsIAnnotationService);
|
||||
@@ -129,6 +128,7 @@ var Services = Module("Services", {
|
||||
*/
|
||||
add: function (name, class_, ifaces, meth) {
|
||||
const self = this;
|
||||
this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []) };
|
||||
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
|
||||
throw TypeError();
|
||||
memoize(this, name, function () self._create(class_, ifaces, meth));
|
||||
@@ -164,11 +164,18 @@ var Services = Module("Services", {
|
||||
* @param {string} name The service's cache key.
|
||||
*/
|
||||
get: function (name) this[name],
|
||||
|
||||
/**
|
||||
* Returns true if the given service is available.
|
||||
*
|
||||
* @param {string} name The service's cache key.
|
||||
*/
|
||||
has: function (name) set.has(this.services, name) && this.services[name].class in Cc &&
|
||||
this.services[name].interfaces.every(function (iface) iface in Ci)
|
||||
}, {
|
||||
}, {
|
||||
javascript: function (dactyl, modules) {
|
||||
modules.JavaScript.setCompleter(this.get, [function () [[k, v] for ([k, v] in Iterator(services)) if (v instanceof Ci.nsISupports)]]);
|
||||
modules.JavaScript.setCompleter(this.create, [function () [[c, ""] for (c in services.classes)]]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1430,6 +1430,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
||||
if (error.noTrace)
|
||||
return;
|
||||
|
||||
if (isString(error))
|
||||
error = Error(error);
|
||||
|
||||
if (Cu.reportError)
|
||||
Cu.reportError(error);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user