mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 14:02:28 +01:00
Fix bugs and stuff.
This commit is contained in:
27
common/bootstrap.js
vendored
27
common/bootstrap.js
vendored
@@ -56,12 +56,15 @@ let addon = null;
|
|||||||
let addonData = null;
|
let addonData = null;
|
||||||
let basePath = null;
|
let basePath = null;
|
||||||
let bootstrap;
|
let bootstrap;
|
||||||
|
let bootstrap_jsm;
|
||||||
let categories = [];
|
let categories = [];
|
||||||
let components = {};
|
let components = {};
|
||||||
let resources = [];
|
let resources = [];
|
||||||
let getURI = null;
|
let getURI = null;
|
||||||
|
|
||||||
let JSMLoader = {
|
let JSMLoader = {
|
||||||
|
SANDBOX: Cu.nukeSandbox && false,
|
||||||
|
|
||||||
get addon() addon,
|
get addon() addon,
|
||||||
|
|
||||||
currentModule: null,
|
currentModule: null,
|
||||||
@@ -131,7 +134,7 @@ let JSMLoader = {
|
|||||||
return this.modules[name] = this.globals[uri];
|
return this.modules[name] = this.globals[uri];
|
||||||
|
|
||||||
this.globals[uri] = this.modules[name];
|
this.globals[uri] = this.modules[name];
|
||||||
bootstrap.loadSubScript(url, this.modules[name]);
|
bootstrap_jsm.loadSubScript(url, this.modules[name]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
@@ -175,7 +178,7 @@ let JSMLoader = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Cuts down on stupid, fscking url mangling.
|
// Cuts down on stupid, fscking url mangling.
|
||||||
get loadSubScript() bootstrap.loadSubScript,
|
get loadSubScript() bootstrap_jsm.loadSubScript,
|
||||||
|
|
||||||
cleanup: function unregister() {
|
cleanup: function unregister() {
|
||||||
for each (let factory in this.factories.splice(0))
|
for each (let factory in this.factories.splice(0))
|
||||||
@@ -242,7 +245,14 @@ function init() {
|
|||||||
|
|
||||||
JSMLoader.config = JSON.parse(httpGet("resource://dactyl-local/config.json").responseText);
|
JSMLoader.config = JSON.parse(httpGet("resource://dactyl-local/config.json").responseText);
|
||||||
|
|
||||||
bootstrap = module(BOOTSTRAP);
|
bootstrap_jsm = module(BOOTSTRAP);
|
||||||
|
if (!JSMLoader.SANDBOX)
|
||||||
|
bootstrap = bootstrap_jsm;
|
||||||
|
else {
|
||||||
|
bootstrap = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance(),
|
||||||
|
{ sandboxName: BOOTSTRAP });
|
||||||
|
Services.scriptloader.loadSubScript(BOOTSTRAP, bootstrap);
|
||||||
|
}
|
||||||
bootstrap.require = JSMLoader.load("base").require;
|
bootstrap.require = JSMLoader.load("base").require;
|
||||||
|
|
||||||
// Flush the cache if necessary, just to be paranoid
|
// Flush the cache if necessary, just to be paranoid
|
||||||
@@ -273,7 +283,7 @@ function init() {
|
|||||||
|
|
||||||
if (!(BOOTSTRAP_CONTRACT in Cc)) {
|
if (!(BOOTSTRAP_CONTRACT in Cc)) {
|
||||||
// Use Sandbox to prevent closures over this scope
|
// Use Sandbox to prevent closures over this scope
|
||||||
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].getService());
|
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance());
|
||||||
let factory = Cu.evalInSandbox("({ createInstance: function () this })", sandbox);
|
let factory = Cu.evalInSandbox("({ createInstance: function () this })", sandbox);
|
||||||
|
|
||||||
factory.classID = Components.ID("{f541c8b0-fe26-4621-a30b-e77d21721fb5}");
|
factory.classID = Components.ID("{f541c8b0-fe26-4621-a30b-e77d21721fb5}");
|
||||||
@@ -416,11 +426,12 @@ function shutdown(data, reason) {
|
|||||||
JSMLoader.atexit(strReason);
|
JSMLoader.atexit(strReason);
|
||||||
JSMLoader.cleanup(strReason);
|
JSMLoader.cleanup(strReason);
|
||||||
|
|
||||||
if (Cu.unload)
|
if (JSMLoader.SANDBOX)
|
||||||
|
Cu.nukeSandbox(bootstrap);
|
||||||
|
bootstrap_jsm.require = null;
|
||||||
Cu.unload(BOOTSTRAP);
|
Cu.unload(BOOTSTRAP);
|
||||||
else
|
bootstrap = null;
|
||||||
bootstrap.require = null;
|
bootstrap_jsm = null;
|
||||||
|
|
||||||
|
|
||||||
for each (let [category, entry] in categories)
|
for each (let [category, entry] in categories)
|
||||||
categoryManager.deleteCategoryEntry(category, entry, false);
|
categoryManager.deleteCategoryEntry(category, entry, false);
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ var Bookmarks = Module("bookmarks", {
|
|||||||
|
|
||||||
checkBookmarked: function checkBookmarked(uri) {
|
checkBookmarked: function checkBookmarked(uri) {
|
||||||
if (PlacesUtils.asyncGetBookmarkIds)
|
if (PlacesUtils.asyncGetBookmarkIds)
|
||||||
PlacesUtils.asyncGetBookmarkIds(uri, function (ids) {
|
PlacesUtils.asyncGetBookmarkIds(uri, function withBookmarkIDs(ids) {
|
||||||
statusline.bookmarked = ids.length;
|
statusline.bookmarked = ids.length;
|
||||||
});
|
});
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -467,11 +467,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {Object} context The context object into which the script
|
* @param {Object} context The context object into which the script
|
||||||
* should be loaded.
|
* should be loaded.
|
||||||
*/
|
*/
|
||||||
loadScript: function (uri, context) {
|
loadScript: function loadScript(uri, context) {
|
||||||
JSMLoader.loadSubScript(uri, context, File.defaultEncoding);
|
JSMLoader.loadSubScript(uri, context, File.defaultEncoding);
|
||||||
},
|
},
|
||||||
|
|
||||||
userEval: function (str, context, fileName, lineNumber) {
|
userEval: function userEval(str, context, fileName, lineNumber) {
|
||||||
let ctxt;
|
let ctxt;
|
||||||
if (jsmodules.__proto__ != window && jsmodules.__proto__ != XPCNativeWrapper(window) &&
|
if (jsmodules.__proto__ != window && jsmodules.__proto__ != XPCNativeWrapper(window) &&
|
||||||
jsmodules.isPrototypeOf(context))
|
jsmodules.isPrototypeOf(context))
|
||||||
@@ -523,7 +523,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* Acts like the Function builtin, but the code executes in the
|
* Acts like the Function builtin, but the code executes in the
|
||||||
* userContext global.
|
* userContext global.
|
||||||
*/
|
*/
|
||||||
userFunc: function () {
|
userFunc: function userFunc() {
|
||||||
return this.userEval(
|
return this.userEval(
|
||||||
"(function userFunction(" + Array.slice(arguments, 0, -1).join(", ") + ")" +
|
"(function userFunction(" + Array.slice(arguments, 0, -1).join(", ") + ")" +
|
||||||
" { " + arguments[arguments.length - 1] + " })");
|
" { " + arguments[arguments.length - 1] + " })");
|
||||||
@@ -538,7 +538,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {boolean} silent Whether the command should be echoed on the
|
* @param {boolean} silent Whether the command should be echoed on the
|
||||||
* command line.
|
* command line.
|
||||||
*/
|
*/
|
||||||
execute: function (str, modifiers, silent) {
|
execute: function execute(str, modifiers, silent) {
|
||||||
// skip comments and blank lines
|
// skip comments and blank lines
|
||||||
if (/^\s*("|$)/.test(str))
|
if (/^\s*("|$)/.test(str))
|
||||||
return;
|
return;
|
||||||
@@ -622,7 +622,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {string} feature The feature name.
|
* @param {string} feature The feature name.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
has: function (feature) Set.has(config.features, feature),
|
has: function has(feature) Set.has(config.features, feature),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -762,7 +762,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
get: function globalVariables() this._globalVariables
|
get: function globalVariables() this._globalVariables
|
||||||
}),
|
}),
|
||||||
|
|
||||||
loadPlugins: function (args, force) {
|
loadPlugins: function loadPlugins(args, force) {
|
||||||
function sourceDirectory(dir) {
|
function sourceDirectory(dir) {
|
||||||
dactyl.assert(dir.isReadable(), _("io.notReadable", dir.path));
|
dactyl.assert(dir.isReadable(), _("io.notReadable", dir.path));
|
||||||
|
|
||||||
@@ -819,7 +819,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {string|Object} msg The message to print.
|
* @param {string|Object} msg The message to print.
|
||||||
* @param {number} level The logging level 0 - 15.
|
* @param {number} level The logging level 0 - 15.
|
||||||
*/
|
*/
|
||||||
log: function (msg, level) {
|
log: function log(msg, level) {
|
||||||
let verbose = config.prefs.get("loglevel", 0);
|
let verbose = config.prefs.get("loglevel", 0);
|
||||||
|
|
||||||
if (!level || level <= verbose) {
|
if (!level || level <= verbose) {
|
||||||
@@ -889,7 +889,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* tabs.
|
* tabs.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
open: function (urls, params, force) {
|
open: function open(urls, params, force) {
|
||||||
if (typeof urls == "string")
|
if (typeof urls == "string")
|
||||||
urls = dactyl.parseURLs(urls);
|
urls = dactyl.parseURLs(urls);
|
||||||
|
|
||||||
@@ -1078,7 +1078,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @param {boolean} force Forcibly quit irrespective of whether all
|
* @param {boolean} force Forcibly quit irrespective of whether all
|
||||||
* windows could be closed individually.
|
* windows could be closed individually.
|
||||||
*/
|
*/
|
||||||
quit: function (saveSession, force) {
|
quit: function quit(saveSession, force) {
|
||||||
if (!force && !this.confirmQuit())
|
if (!force && !this.confirmQuit())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1095,7 +1095,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
/**
|
/**
|
||||||
* Restart the host application.
|
* Restart the host application.
|
||||||
*/
|
*/
|
||||||
restart: function (args) {
|
restart: function restart(args) {
|
||||||
if (!this.confirmQuit())
|
if (!this.confirmQuit())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1171,7 +1171,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
* @see Commands#parseArgs
|
* @see Commands#parseArgs
|
||||||
*/
|
*/
|
||||||
parseCommandLine: function (cmdline) {
|
parseCommandLine: function parseCommandLine(cmdline) {
|
||||||
try {
|
try {
|
||||||
return commands.get("rehash").parseArgs(cmdline);
|
return commands.get("rehash").parseArgs(cmdline);
|
||||||
}
|
}
|
||||||
@@ -1180,7 +1180,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
wrapCallback: function (callback, self) {
|
wrapCallback: function wrapCallback(callback, self) {
|
||||||
self = self || this;
|
self = self || this;
|
||||||
let save = ["forceOpen"];
|
let save = ["forceOpen"];
|
||||||
let saved = save.map(function (p) dactyl[p]);
|
let saved = save.map(function (p) dactyl[p]);
|
||||||
@@ -1616,13 +1616,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
"Reload the " + config.appName + " add-on",
|
"Reload the " + config.appName + " add-on",
|
||||||
function (args) {
|
function (args) {
|
||||||
if (args.trailing)
|
if (args.trailing)
|
||||||
storage.session.rehashCmd = args.trailing; // Hack.
|
storage.storeForSession("rehashCmd", args.trailing); // Hack.
|
||||||
args.break = true;
|
args.break = true;
|
||||||
|
|
||||||
if (args["+purgecaches"])
|
if (args["+purgecaches"])
|
||||||
cache.flush();
|
cache.flush();
|
||||||
|
|
||||||
util.rehash(args);
|
util.delay(function () { util.rehash(args) });
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "0", // FIXME
|
argCount: "0", // FIXME
|
||||||
|
|||||||
@@ -862,7 +862,7 @@ var Hints = Module("hints", {
|
|||||||
}
|
}
|
||||||
else if (option == "label") {
|
else if (option == "label") {
|
||||||
if (elem.id) {
|
if (elem.id) {
|
||||||
let label = elem.ownerDocument.dactylLabels[elem.id];
|
let label = (elem.ownerDocument.dactylLabels || {})[elem.id];
|
||||||
if (label)
|
if (label)
|
||||||
return [label.textContent.toLowerCase(), true];
|
return [label.textContent.toLowerCase(), true];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ defineModule("base", {
|
|||||||
"debuggerProperties", "defineModule", "deprecated", "endModule", "forEach", "isArray",
|
"debuggerProperties", "defineModule", "deprecated", "endModule", "forEach", "isArray",
|
||||||
"isGenerator", "isinstance", "isObject", "isString", "isSubclass", "isXML", "iter",
|
"isGenerator", "isinstance", "isObject", "isString", "isSubclass", "isXML", "iter",
|
||||||
"iterAll", "iterOwnProperties", "keys", "literal", "memoize", "octal", "properties",
|
"iterAll", "iterOwnProperties", "keys", "literal", "memoize", "octal", "properties",
|
||||||
"require", "set", "update", "values"
|
"require", "set", "update", "values", "update_"
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -598,7 +598,7 @@ function memoize(obj, key, getter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sandbox = Cu.Sandbox(Cu.getGlobalForObject(this));
|
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance());
|
||||||
sandbox.__proto__ = this;
|
sandbox.__proto__ = this;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -632,7 +632,7 @@ function update(target) {
|
|||||||
if (typeof desc.value === "function" && target.__proto__ && !(desc.value instanceof Ci.nsIDOMElement /* wtf? */)) {
|
if (typeof desc.value === "function" && target.__proto__ && !(desc.value instanceof Ci.nsIDOMElement /* wtf? */)) {
|
||||||
let func = desc.value.wrapped || desc.value;
|
let func = desc.value.wrapped || desc.value;
|
||||||
if (!func.superapply) {
|
if (!func.superapply) {
|
||||||
func.__defineGetter__("super", function () Object.getPrototypeOf(target)[k]);
|
func.__defineGetter__("super", function get_super() Object.getPrototypeOf(target)[k]);
|
||||||
func.superapply = function superapply(self, args)
|
func.superapply = function superapply(self, args)
|
||||||
let (meth = Object.getPrototypeOf(target)[k])
|
let (meth = Object.getPrototypeOf(target)[k])
|
||||||
meth && meth.apply(self, args);
|
meth && meth.apply(self, args);
|
||||||
@@ -647,6 +647,33 @@ function update(target) {
|
|||||||
}
|
}
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
function update_(target) {
|
||||||
|
for (let i = 1; i < arguments.length; i++) {
|
||||||
|
let src = arguments[i];
|
||||||
|
Object.getOwnPropertyNames(src || {}).forEach(function (k) {
|
||||||
|
let desc = Object.getOwnPropertyDescriptor(src, k);
|
||||||
|
if (desc.value instanceof Class.Property)
|
||||||
|
desc = desc.value.init(k, target) || desc.value;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (typeof desc.value === "function" && target.__proto__ && !(desc.value instanceof Ci.nsIDOMElement /* wtf? */)) {
|
||||||
|
let func = desc.value.wrapped || desc.value;
|
||||||
|
if (!func.superapply) {
|
||||||
|
func.__defineGetter__("super", function get_super_() Object.getPrototypeOf(target)[k]);
|
||||||
|
func.superapply = function super_apply(self, args)
|
||||||
|
let (meth = Object.getPrototypeOf(target)[k])
|
||||||
|
meth && meth.apply(self, args);
|
||||||
|
func.supercall = function super_call(self)
|
||||||
|
func.superapply(self, Array.slice(arguments, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object.defineProperty(target, k, desc);
|
||||||
|
}
|
||||||
|
catch (e) {}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor Class
|
* @constructor Class
|
||||||
|
|||||||
@@ -176,6 +176,8 @@ var ObjectStore = Class("ObjectStore", StoreBase, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var sessionGlobal = Cu.import("resource://gre/modules/Services.jsm", {})
|
||||||
|
|
||||||
var Storage = Module("Storage", {
|
var Storage = Module("Storage", {
|
||||||
alwaysReload: {},
|
alwaysReload: {},
|
||||||
|
|
||||||
@@ -184,7 +186,7 @@ var Storage = Module("Storage", {
|
|||||||
|
|
||||||
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
|
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||||
if (!Services.dactylSession)
|
if (!Services.dactylSession)
|
||||||
Services.dactylSession = {};
|
Services.dactylSession = Cu.createObjectIn(sessionGlobal);
|
||||||
this.session = Services.dactylSession;
|
this.session = Services.dactylSession;
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -201,6 +203,13 @@ var Storage = Module("Storage", {
|
|||||||
this.observers = {};
|
this.observers = {};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
storeForSession: function storeForSession(key, val) {
|
||||||
|
if (val)
|
||||||
|
this.session[key] = sessionGlobal.JSON.parse(JSON.stringify(val));
|
||||||
|
else
|
||||||
|
delete this.dactylSession[key];
|
||||||
|
},
|
||||||
|
|
||||||
infoPath: Class.Memoize(function ()
|
infoPath: Class.Memoize(function ()
|
||||||
File(IO.runtimePath.replace(/,.*/, ""))
|
File(IO.runtimePath.replace(/,.*/, ""))
|
||||||
.child("info").child(config.profileName)),
|
.child("info").child(config.profileName)),
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ var Template = Module("Template", {
|
|||||||
!(item.extra && item.extra.length) ? [] :
|
!(item.extra && item.extra.length) ? [] :
|
||||||
["span", { highlight: "URLExtra" },
|
["span", { highlight: "URLExtra" },
|
||||||
" (",
|
" (",
|
||||||
this.map(item.extra, function (e)
|
template.map(item.extra, function (e)
|
||||||
["", e[0], ": ",
|
["", e[0], ": ",
|
||||||
["span", { highlight: e[2] }, e[1]]],
|
["span", { highlight: e[2] }, e[1]]],
|
||||||
"\u00a0"),
|
"\u00a0"),
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ var wrapCallback = function wrapCallback(fn, isEvent) {
|
|||||||
var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||||
Magic: Magic,
|
Magic: Magic,
|
||||||
|
|
||||||
init: function () {
|
init: function init() {
|
||||||
this.Array = array;
|
this.Array = array;
|
||||||
|
|
||||||
this.addObserver(this);
|
this.addObserver(this);
|
||||||
@@ -104,7 +104,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
var global = Class.objectGlobal(obj);
|
var global = Class.objectGlobal(obj);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
__noSuchMethod__: function (meth, args) {
|
__noSuchMethod__: function __noSuchMethod__(meth, args) {
|
||||||
let win = overlay.activeWindow;
|
let win = overlay.activeWindow;
|
||||||
|
|
||||||
var dactyl = global && global.dactyl || win && win.dactyl;
|
var dactyl = global && global.dactyl || win && win.dactyl;
|
||||||
@@ -118,7 +118,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, {
|
}, {
|
||||||
__noSuchMethod__: function () this().__noSuchMethod__.apply(null, arguments)
|
__noSuchMethod__: function __noSuchMethod__() this().__noSuchMethod__.apply(null, arguments)
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,7 +173,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {string} message The message to present to the
|
* @param {string} message The message to present to the
|
||||||
* user on failure.
|
* user on failure.
|
||||||
*/
|
*/
|
||||||
assert: function (condition, message, quiet) {
|
assert: function assert(condition, message, quiet) {
|
||||||
if (!condition)
|
if (!condition)
|
||||||
throw FailedAssertion(message, 1, quiet === undefined ? true : quiet);
|
throw FailedAssertion(message, 1, quiet === undefined ? true : quiet);
|
||||||
return condition;
|
return condition;
|
||||||
@@ -266,7 +266,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
{
|
{
|
||||||
elements: [],
|
elements: [],
|
||||||
seen: {},
|
seen: {},
|
||||||
valid: function (obj) this.elements.every(function (e) !e.test || e.test(obj))
|
valid: function valid(obj) this.elements.every(function (e) !e.test || e.test(obj))
|
||||||
});
|
});
|
||||||
|
|
||||||
let end = 0;
|
let end = 0;
|
||||||
@@ -296,7 +296,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
|
|
||||||
stack.top.elements.push(update(
|
stack.top.elements.push(update(
|
||||||
function (obj) obj[char] != null ? quote(obj, char) : "",
|
function (obj) obj[char] != null ? quote(obj, char) : "",
|
||||||
{ test: function (obj) obj[char] != null }));
|
{ test: function test(obj) obj[char] != null }));
|
||||||
|
|
||||||
for (let elem in array.iterValues(stack))
|
for (let elem in array.iterValues(stack))
|
||||||
elem.seen[char] = true;
|
elem.seen[char] = true;
|
||||||
@@ -349,7 +349,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
{
|
{
|
||||||
elements: [],
|
elements: [],
|
||||||
seen: {},
|
seen: {},
|
||||||
valid: function (obj) this.elements.every(function (e) !e.test || e.test(obj))
|
valid: function valid(obj) this.elements.every(function (e) !e.test || e.test(obj))
|
||||||
});
|
});
|
||||||
|
|
||||||
let defaults = { lt: "<", gt: ">" };
|
let defaults = { lt: "<", gt: ">" };
|
||||||
@@ -399,7 +399,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
function (obj) obj[name] != null && idx in obj[name] ? quote(obj[name][idx])
|
function (obj) obj[name] != null && idx in obj[name] ? quote(obj[name][idx])
|
||||||
: Set.has(obj, name) ? "" : unknown(full),
|
: Set.has(obj, name) ? "" : unknown(full),
|
||||||
{
|
{
|
||||||
test: function (obj) obj[name] != null && idx in obj[name]
|
test: function test(obj) obj[name] != null && idx in obj[name]
|
||||||
&& obj[name][idx] !== false
|
&& obj[name][idx] !== false
|
||||||
&& (!flags.e || obj[name][idx] != "")
|
&& (!flags.e || obj[name][idx] != "")
|
||||||
}));
|
}));
|
||||||
@@ -409,7 +409,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
function (obj) obj[name] != null ? quote(obj[name])
|
function (obj) obj[name] != null ? quote(obj[name])
|
||||||
: Set.has(obj, name) ? "" : unknown(full),
|
: Set.has(obj, name) ? "" : unknown(full),
|
||||||
{
|
{
|
||||||
test: function (obj) obj[name] != null
|
test: function test(obj) obj[name] != null
|
||||||
&& obj[name] !== false
|
&& obj[name] !== false
|
||||||
&& (!flags.e || obj[name] != "")
|
&& (!flags.e || obj[name] != "")
|
||||||
}));
|
}));
|
||||||
@@ -519,6 +519,17 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Briefly delay the execution of the passed function.
|
||||||
|
*
|
||||||
|
* @param {function} callback The function to delay.
|
||||||
|
*/
|
||||||
|
delay: function delay(callback) {
|
||||||
|
let { mainThread } = services.threading;
|
||||||
|
mainThread.dispatch(callback,
|
||||||
|
mainThread.DISPATCH_NORMAL);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes certain backslash-quoted characters while leaving other
|
* Removes certain backslash-quoted characters while leaving other
|
||||||
* backslash-quoting sequences untouched.
|
* backslash-quoting sequences untouched.
|
||||||
@@ -556,7 +567,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {string} stack The stack trace from an Error.
|
* @param {string} stack The stack trace from an Error.
|
||||||
* @returns {[string]} The stack frames.
|
* @returns {[string]} The stack frames.
|
||||||
*/
|
*/
|
||||||
stackLines: function (stack) {
|
stackLines: function stackLines(stack) {
|
||||||
let lines = [];
|
let lines = [];
|
||||||
let match, re = /([^]*?)@([^@\n]*)(?:\n|$)/g;
|
let match, re = /([^]*?)@([^@\n]*)(?:\n|$)/g;
|
||||||
while (match = re.exec(stack))
|
while (match = re.exec(stack))
|
||||||
@@ -688,7 +699,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @returns {string|null}
|
* @returns {string|null}
|
||||||
*/
|
*/
|
||||||
getHost: function (url) {
|
getHost: function getHost(url) {
|
||||||
try {
|
try {
|
||||||
return util.createURI(url).host;
|
return util.createURI(url).host;
|
||||||
}
|
}
|
||||||
@@ -809,7 +820,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {Object} r2
|
* @param {Object} r2
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
intersection: function (r1, r2) ({
|
intersection: function intersection(r1, r2) ({
|
||||||
get width() this.right - this.left,
|
get width() this.right - this.left,
|
||||||
get height() this.bottom - this.top,
|
get height() this.bottom - this.top,
|
||||||
left: Math.max(r1.left, r2.left),
|
left: Math.max(r1.left, r2.left),
|
||||||
@@ -1031,6 +1042,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
|
|
||||||
if (color)
|
if (color)
|
||||||
value = template.highlight(value, true, 150, !color);
|
value = template.highlight(value, true, 150, !color);
|
||||||
|
else if (value instanceof Magic)
|
||||||
|
value = String(value);
|
||||||
else
|
else
|
||||||
value = util.clip(String(value).replace(/\n/g, "^J"), 150);
|
value = util.clip(String(value).replace(/\n/g, "^J"), 150);
|
||||||
|
|
||||||
@@ -1121,7 +1134,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
},
|
},
|
||||||
|
|
||||||
observers: {
|
observers: {
|
||||||
"dactyl-cleanup-modules": function (subject, reason) {
|
"dactyl-cleanup-modules": function cleanupModules(subject, reason) {
|
||||||
defineModule.loadLog.push("dactyl: util: observe: dactyl-cleanup-modules " + reason);
|
defineModule.loadLog.push("dactyl: util: observe: dactyl-cleanup-modules " + reason);
|
||||||
|
|
||||||
for (let module in values(defineModule.modules))
|
for (let module in values(defineModule.modules))
|
||||||
@@ -1135,7 +1148,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
if (!this.rehashing)
|
if (!this.rehashing)
|
||||||
services.observer.addObserver(this, "dactyl-rehash", true);
|
services.observer.addObserver(this, "dactyl-rehash", true);
|
||||||
},
|
},
|
||||||
"dactyl-rehash": function () {
|
"dactyl-rehash": function dactylRehash() {
|
||||||
services.observer.removeObserver(this, "dactyl-rehash");
|
services.observer.removeObserver(this, "dactyl-rehash");
|
||||||
|
|
||||||
defineModule.loadLog.push("dactyl: util: observe: dactyl-rehash");
|
defineModule.loadLog.push("dactyl: util: observe: dactyl-rehash");
|
||||||
@@ -1148,7 +1161,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
module.init();
|
module.init();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dactyl-purge": function () {
|
"dactyl-purge": function dactylPurge() {
|
||||||
this.rehashing = 1;
|
this.rehashing = 1;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1258,7 +1271,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
let res = update(RegExp(expr, flags.replace("x", "")), {
|
let res = update(RegExp(expr, flags.replace("x", "")), {
|
||||||
closure: Class.Property(Object.getOwnPropertyDescriptor(Class.prototype, "closure")),
|
closure: Class.Property(Object.getOwnPropertyDescriptor(Class.prototype, "closure")),
|
||||||
dactylPropertyNames: ["exec", "match", "test", "toSource", "toString", "global", "ignoreCase", "lastIndex", "multiLine", "source", "sticky"],
|
dactylPropertyNames: ["exec", "match", "test", "toSource", "toString", "global", "ignoreCase", "lastIndex", "multiLine", "source", "sticky"],
|
||||||
iterate: function (str, idx) util.regexp.iterate(this, str, idx)
|
iterate: function iterate(str, idx) util.regexp.iterate(this, str, idx)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Return a struct with properties for named parameters if we
|
// Return a struct with properties for named parameters if we
|
||||||
@@ -1321,8 +1334,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* Reloads dactyl in entirety by disabling the add-on and
|
* Reloads dactyl in entirety by disabling the add-on and
|
||||||
* re-enabling it.
|
* re-enabling it.
|
||||||
*/
|
*/
|
||||||
rehash: function (args) {
|
rehash: function rehash(args) {
|
||||||
storage.session.commandlineArgs = args;
|
storage.storeForSession("commandlineArgs", args);
|
||||||
this.timeout(function () {
|
this.timeout(function () {
|
||||||
this.flushCache();
|
this.flushCache();
|
||||||
this.rehashing = true;
|
this.rehashing = true;
|
||||||
@@ -1408,7 +1421,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {Window} window
|
* @param {Window} window
|
||||||
* @returns {nsISelectionController}
|
* @returns {nsISelectionController}
|
||||||
*/
|
*/
|
||||||
selectionController: function (win)
|
selectionController: function selectionController(win)
|
||||||
win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
|
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsISelectionDisplay)
|
||||||
.QueryInterface(Ci.nsISelectionController),
|
.QueryInterface(Ci.nsISelectionController),
|
||||||
@@ -1427,7 +1440,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
*
|
*
|
||||||
* @param {number} delay The time period for which to sleep in milliseconds.
|
* @param {number} delay The time period for which to sleep in milliseconds.
|
||||||
*/
|
*/
|
||||||
sleep: function (delay) {
|
sleep: function sleep(delay) {
|
||||||
let mainThread = services.threading.mainThread;
|
let mainThread = services.threading.mainThread;
|
||||||
|
|
||||||
let end = Date.now() + delay;
|
let end = Date.now() + delay;
|
||||||
@@ -1448,7 +1461,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {number} limit The maximum number of elements to return.
|
* @param {number} limit The maximum number of elements to return.
|
||||||
* @returns {[string]}
|
* @returns {[string]}
|
||||||
*/
|
*/
|
||||||
split: function (str, re, limit) {
|
split: function split(str, re, limit) {
|
||||||
re.lastIndex = 0;
|
re.lastIndex = 0;
|
||||||
if (!re.global)
|
if (!re.global)
|
||||||
re = RegExp(re.source || re, "g");
|
re = RegExp(re.source || re, "g");
|
||||||
@@ -1508,7 +1521,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* interrupted by pressing <C-c>, in which case,
|
* interrupted by pressing <C-c>, in which case,
|
||||||
* Error("Interrupted") will be thrown.
|
* Error("Interrupted") will be thrown.
|
||||||
*/
|
*/
|
||||||
threadYield: function (flush, interruptable) {
|
threadYield: function threadYield(flush, interruptable) {
|
||||||
this.yielders++;
|
this.yielders++;
|
||||||
try {
|
try {
|
||||||
let mainThread = services.threading.mainThread;
|
let mainThread = services.threading.mainThread;
|
||||||
@@ -1647,7 +1660,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {nsIDOMWindow} win The window for which to find domains.
|
* @param {nsIDOMWindow} win The window for which to find domains.
|
||||||
* @returns {[string]} The visible domains.
|
* @returns {[string]} The visible domains.
|
||||||
*/
|
*/
|
||||||
visibleHosts: function (win) {
|
visibleHosts: function visibleHosts(win) {
|
||||||
let res = [], seen = {};
|
let res = [], seen = {};
|
||||||
(function rec(frame) {
|
(function rec(frame) {
|
||||||
try {
|
try {
|
||||||
@@ -1667,7 +1680,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
|
|||||||
* @param {nsIDOMWindow} win The window for which to find URIs.
|
* @param {nsIDOMWindow} win The window for which to find URIs.
|
||||||
* @returns {[nsIURI]} The visible URIs.
|
* @returns {[nsIURI]} The visible URIs.
|
||||||
*/
|
*/
|
||||||
visibleURIs: function (win) {
|
visibleURIs: function visibleURIs(win) {
|
||||||
let res = [], seen = {};
|
let res = [], seen = {};
|
||||||
(function rec(frame) {
|
(function rec(frame) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
- renamed :mksyntax to :mkvimruntime which now generates
|
- renamed :mksyntax to :mkvimruntime which now generates
|
||||||
all Vim related files.
|
all Vim related files.
|
||||||
- Vimball packages are no longer available.
|
- Vimball packages are no longer available.
|
||||||
|
• Removed <F1> and <A-F1> mappings.
|
||||||
|
|
||||||
1.0:
|
1.0:
|
||||||
• Extensive Firefox 4 support, including:
|
• Extensive Firefox 4 support, including:
|
||||||
|
|||||||
Reference in New Issue
Block a user