mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-10 18:05:46 +01:00
Another attempt at revision 8613b76cff40.
This commit is contained in:
@@ -147,6 +147,9 @@ defineModule.modules = [];
|
||||
defineModule.times = { all: 0 };
|
||||
defineModule.time = function time(major, minor, func, self) {
|
||||
let time = Date.now();
|
||||
if (typeof func !== "function")
|
||||
func = self[func];
|
||||
|
||||
try {
|
||||
var res = func.apply(self, Array.slice(arguments, 4));
|
||||
}
|
||||
@@ -913,7 +916,7 @@ Module.INIT = {
|
||||
for (let i in locals)
|
||||
module = objs[i] = Object.create(module);
|
||||
|
||||
modules[this.constructor.className] = module;
|
||||
modules.jsmodules[this.constructor.className] = module;
|
||||
locals.reverse().forEach(function (fn, i) update(objs[i], fn.apply(module, args)))
|
||||
module.instance = module;
|
||||
module.init();
|
||||
|
||||
@@ -117,6 +117,28 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
|
||||
|
||||
isBookmark: function (id) this.rootFolders.indexOf(this.findRoot(id)) >= 0,
|
||||
|
||||
/**
|
||||
* Returns true if the given URL is bookmarked and that bookmark is
|
||||
* not a Live Bookmark.
|
||||
*
|
||||
* @param {nsIURI|string} url The URL of which to check the bookmarked
|
||||
* state.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
isBookmarked: function isBookmarked(uri) {
|
||||
if (isString(uri))
|
||||
uri = util.newURI(uri);
|
||||
|
||||
try {
|
||||
return services.bookmarks
|
||||
.getBookmarkIdsForURI(uri, {})
|
||||
.some(this.closure.isRegularBookmark);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
isRegularBookmark: function isRegularBookmark(id) {
|
||||
do {
|
||||
var root = id;
|
||||
|
||||
@@ -844,7 +844,7 @@ var Completion = Module("completion", {
|
||||
get setFunctionCompleter() JavaScript.setCompleter, // Backward compatibility
|
||||
|
||||
Local: function (dactyl, modules, window) ({
|
||||
options: modules.options,
|
||||
get options() modules.options,
|
||||
|
||||
// FIXME
|
||||
_runCompleter: function _runCompleter(name, filter, maxItems) {
|
||||
|
||||
@@ -162,7 +162,7 @@ var RangeFinder = Module("rangefinder", {
|
||||
}, {
|
||||
}, {
|
||||
modes: function (dactyl, modules, window) {
|
||||
const { commandline, modes } = modules;
|
||||
const { modes } = modules;
|
||||
modes.addMode("FIND", {
|
||||
extended: true,
|
||||
description: "Find mode, active when typing search input",
|
||||
|
||||
@@ -679,9 +679,11 @@ var JavaScript = Module("javascript", {
|
||||
init.superapply(this, arguments);
|
||||
},
|
||||
completion: function (dactyl, modules, window) {
|
||||
const { completion, javascript } = modules;
|
||||
completion.javascript = javascript.closure.complete;
|
||||
completion.javascriptCompleter = JavaScript; // Backwards compatibility.
|
||||
const { completion } = modules;
|
||||
update(modules.completion, {
|
||||
get javascript() modules.javascript.closure.complete,
|
||||
javascriptCompleter: JavaScript // Backwards compatibility
|
||||
});
|
||||
},
|
||||
options: function (dactyl, modules, window) {
|
||||
modules.options.add(["jsdebugger", "jsd"],
|
||||
|
||||
@@ -246,9 +246,11 @@ var Overlay = Module("Overlay", {
|
||||
defineModule.loadLog.push(" from: " + util.fixURI(frame.filename) + ":" + frame.lineNumber);
|
||||
|
||||
delete modules[module.className];
|
||||
// util.dump("INIT: " + module.className);
|
||||
modules[module.className] = defineModule.time(module.className, "init", module);
|
||||
frob(module.className);
|
||||
|
||||
init(modules[module.className]);
|
||||
// init(modules[module.className]);
|
||||
}
|
||||
catch (e) {
|
||||
util.dump("Loading " + (module && module.className) + ":");
|
||||
@@ -257,16 +259,45 @@ var Overlay = Module("Overlay", {
|
||||
return modules[module.className];
|
||||
}
|
||||
|
||||
for each (let module in defineModule.modules)
|
||||
if (module.INIT.init)
|
||||
defineModule.time(module.constructor.className, "init",
|
||||
module.INIT.init, module,
|
||||
modules.dactyl, modules, window);
|
||||
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,
|
||||
modules.dactyl, modules, window);
|
||||
});
|
||||
});
|
||||
});
|
||||
defineModule.modules.forEach(function (mod) {
|
||||
Object.keys(mod.INIT).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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
defineModule.modules.map(init);
|
||||
function frob(name) {
|
||||
// util.dump(" ======================== FROB " + name + " ======================== ");
|
||||
(deferredInit[name] || []).forEach(call);
|
||||
}
|
||||
|
||||
Module.list.forEach(load);
|
||||
deferredInit["load"].forEach(call);
|
||||
frob("init");
|
||||
defineModule.modules.forEach(function ({ constructor: { className } }) {
|
||||
modules.__defineGetter__(className, function () {
|
||||
delete modules[className];
|
||||
frob(className);
|
||||
return modules[className];
|
||||
});
|
||||
});
|
||||
|
||||
// Module.list.forEach(load);
|
||||
frob("load");
|
||||
modules.times = update({}, defineModule.times);
|
||||
|
||||
defineModule.loadLog.push("Loaded in " + (Date.now() - start) + "ms");
|
||||
|
||||
Reference in New Issue
Block a user