mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 22:37:58 +01:00
Merge changes from bootstrapped.
This commit is contained in:
@@ -4,14 +4,17 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
const Ci = Components.interfaces, Cc = Components.classes;
|
||||
var global = this;
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
|
||||
.getBranch("extensions.dactyl.");
|
||||
const appName = prefs.getComplexValue("appName", Ci.nsISupportsString).data;
|
||||
const name = prefs.getComplexValue("name", Ci.nsISupportsString).data;
|
||||
var appName = prefs.getComplexValue("appName", Ci.nsISupportsString).data;
|
||||
var name = prefs.getComplexValue("name", Ci.nsISupportsString).data;
|
||||
|
||||
function CommandLineHandler() {
|
||||
this.wrappedJSObject = this;
|
||||
@@ -45,9 +48,9 @@ CommandLineHandler.prototype = {
|
||||
};
|
||||
|
||||
if (XPCOMUtils.generateNSGetFactory)
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]);
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([CommandLineHandler]);
|
||||
else
|
||||
const NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]);
|
||||
var EXPORTED_SYMBOLS = ["NSGetFactory"];
|
||||
var NSGetModule = XPCOMUtils.generateNSGetModule([CommandLineHandler]);
|
||||
var EXPORTED_SYMBOLS = ["NSGetFactory", "global"];
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -12,14 +12,18 @@
|
||||
* By Kris Maglione, ideas from Ed Anuff's nsChromeExtensionHandler.
|
||||
*/
|
||||
|
||||
const Ci = Components.interfaces, Cc = Components.classes;
|
||||
var NAME = "protocols";
|
||||
var global = this;
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
|
||||
var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService)
|
||||
.getBranch("extensions.dactyl.");
|
||||
const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
|
||||
var systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
|
||||
|
||||
function dataURL(type, data) "data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data);
|
||||
function makeChannel(url, orig) {
|
||||
@@ -199,9 +203,9 @@ Shim.prototype = {
|
||||
};
|
||||
|
||||
if (XPCOMUtils.generateNSGetFactory)
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutHandler, ChromeData, Dactyl, Shim]);
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([AboutHandler, ChromeData, Dactyl, Shim]);
|
||||
else
|
||||
const NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]);
|
||||
var EXPORTED_SYMBOLS = ["NSGetFactory"];
|
||||
var NSGetModule = XPCOMUtils.generateNSGetModule([AboutHandler, ChromeData, Dactyl, Shim]);
|
||||
var EXPORTED_SYMBOLS = ["NSGetFactory", "global"];
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
@@ -539,6 +539,8 @@ const CommandLine = Module("commandline", {
|
||||
this.widgets.message = null;
|
||||
if (modes.main != modes.COMMAND_LINE)
|
||||
this.widgets.command = null;
|
||||
if ((modes.extended & modes.OUTPUT_MULTILINE) && this.widgets.multilineOutput.atEnd)
|
||||
modes.pop();
|
||||
if (modes.extended != modes.OUTPUT_MULTILINE)
|
||||
this.multilineOutputVisible = false;
|
||||
},
|
||||
|
||||
@@ -1844,8 +1844,7 @@ const Dactyl = Module("dactyl", {
|
||||
|
||||
commands.add(["res[tart]"],
|
||||
"Force " + config.appName + " to restart",
|
||||
function () { dactyl.restart(); },
|
||||
{ argCount: "0" });
|
||||
function () { dactyl.restart(); });
|
||||
|
||||
var toolbox = document.getElementById("navigator-toolbox");
|
||||
if (toolbox) {
|
||||
@@ -2070,6 +2069,7 @@ const Dactyl = Module("dactyl", {
|
||||
if (!services.commandLineHandler)
|
||||
services.add("commandLineHandler", "@mozilla.org/commandlinehandler/general-startup;1?type=" + config.name);
|
||||
|
||||
if (services.commandlinehandler) {
|
||||
let commandline = services.commandLineHandler.optionValue;
|
||||
if (commandline) {
|
||||
let args = dactyl.parseCommandLine(commandline);
|
||||
@@ -2079,6 +2079,7 @@ const Dactyl = Module("dactyl", {
|
||||
dactyl.commandLineOptions.preCommands = args["++cmd"];
|
||||
util.dump("Processing command-line option: " + commandline);
|
||||
}
|
||||
}
|
||||
|
||||
dactyl.log("Command-line options: " + util.objectToString(dactyl.commandLineOptions), 3);
|
||||
|
||||
|
||||
@@ -4,10 +4,49 @@
|
||||
// given in the LICENSE.txt file included with this file.
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
if (!JSMLoader)
|
||||
var JSMLoader = {
|
||||
builtin: Components.utils.Sandbox(this),
|
||||
globals: {},
|
||||
stale: {},
|
||||
load: function load(url, target) {
|
||||
dump("dactyl: load: " + url + "\n");
|
||||
if (this.stale[url]) {
|
||||
delete this.stale[url];
|
||||
dump("dactyl: load stale\n");
|
||||
|
||||
let global = this.globals[url];
|
||||
for each (let prop in Object.getOwnPropertyNames(global))
|
||||
try {
|
||||
if (!set.has(this.builtin, prop) && [this, set].indexOf(global[prop]) < 0)
|
||||
delete global[prop];
|
||||
}
|
||||
catch (e) {}
|
||||
|
||||
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Components.interfaces.mozIJSSubScriptLoader)
|
||||
.loadSubScript(url, this.globals[url]);
|
||||
dump("dactyl: load reloaded: " + url + "\n");
|
||||
}
|
||||
Components.utils.import(url, target);
|
||||
},
|
||||
purge: function purge() {
|
||||
for (let [url, global] in Iterator(this.globals))
|
||||
this.stale[url] = true;
|
||||
},
|
||||
registerGlobal: function registerGlobal(uri, obj) {
|
||||
if (Cu.getGlobalForObject)
|
||||
this.globals[uri.replace(/.* -> /, "")] = Cu.getGlobalForObject(obj);
|
||||
}
|
||||
};
|
||||
|
||||
var Cc = Components.classes;
|
||||
var Ci = Components.interfaces;
|
||||
var Cr = Components.results;
|
||||
var Cu = Components.utils;
|
||||
|
||||
Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication)
|
||||
.storage.set("dactyl.JSMLoader", JSMLoader);
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
try {
|
||||
@@ -98,7 +137,8 @@ let loaded = {};
|
||||
let currentModule;
|
||||
function defineModule(name, params) {
|
||||
let module = Cu.getGlobalForObject ? Cu.getGlobalForObject(params) : params.__parent__;
|
||||
defineModule.globals.push(module);
|
||||
JSMLoader.registerGlobal(Components.stack.caller.filename, module);
|
||||
|
||||
module.NAME = name;
|
||||
module.EXPORTED_SYMBOLS = params.exports || [];
|
||||
defineModule.loadLog.push("defineModule " + name);
|
||||
@@ -115,7 +155,6 @@ function defineModule(name, params) {
|
||||
currentModule = module;
|
||||
}
|
||||
|
||||
defineModule.globals = [];
|
||||
defineModule.loadLog = [];
|
||||
Object.defineProperty(defineModule.loadLog, "push", {
|
||||
value: function (val) { defineModule.dump(val + "\n"); this[this.length] = val; }
|
||||
@@ -162,7 +201,7 @@ function endModule() {
|
||||
function require(obj, name, from) {
|
||||
try {
|
||||
defineModule.loadLog.push((from || "require") + ": loading " + name + " into " + obj.NAME);
|
||||
Cu.import("resource://dactyl/" + name + ".jsm", obj);
|
||||
JSMLoader.load("resource://dactyl/" + name + ".jsm", obj);
|
||||
}
|
||||
catch (e) {
|
||||
defineModule.dump("loading " + String.quote("resource://dactyl/" + name + ".jsm") + "\n");
|
||||
@@ -176,7 +215,7 @@ function require(obj, name, from) {
|
||||
defineModule("base", {
|
||||
// sed -n 's/^(const|function) ([a-zA-Z0-9_]+).*/ "\2",/p' base.jsm | sort | fmt
|
||||
exports: [
|
||||
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "Object", "Runnable",
|
||||
"ErrorBase", "Cc", "Ci", "Class", "Cr", "Cu", "Module", "JSMLoader", "Object", "Runnable",
|
||||
"Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMUtils", "array",
|
||||
"call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule",
|
||||
"deprecated", "endModule", "forEach", "isArray", "isGenerator",
|
||||
@@ -478,7 +517,7 @@ function isSubclass(targ, src) {
|
||||
* @param {object|string|[object|string]} src The types to check targ against.
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isinstance_types = {
|
||||
var isinstance_types = {
|
||||
boolean: Boolean,
|
||||
string: String,
|
||||
function: Function,
|
||||
@@ -513,7 +552,7 @@ function isObject(obj) typeof obj === "object" && obj != null || obj instanceof
|
||||
* any window, frame, namespace, or execution context, which
|
||||
* is not the case when using (obj instanceof Array).
|
||||
*/
|
||||
const isArray =
|
||||
var isArray =
|
||||
Array.isArray
|
||||
// This is bloody stupid.
|
||||
? function isArray(val) Array.isArray(val) || val && val.constructor && val.constructor.name === "Array"
|
||||
@@ -617,7 +656,7 @@ sandbox.__proto__ = this;
|
||||
* is prepended to its arguments.
|
||||
*/
|
||||
// Hack to get around lack of access to caller in strict mode.
|
||||
const withCallerGlobal = Cu.evalInSandbox(<![CDATA[
|
||||
var withCallerGlobal = Cu.evalInSandbox(<![CDATA[
|
||||
(function withCallerGlobal(fn)
|
||||
function withCallerGlobal_wrapped()
|
||||
fn.apply(this,
|
||||
@@ -860,7 +899,7 @@ function XPCOM(interfaces, superClass) {
|
||||
/**
|
||||
* An abstract base class for classes that wish to inherit from Error.
|
||||
*/
|
||||
const ErrorBase = Class("ErrorBase", Error, {
|
||||
var ErrorBase = Class("ErrorBase", Error, {
|
||||
level: 2,
|
||||
init: function (message, level) {
|
||||
level = level || 0;
|
||||
@@ -980,7 +1019,7 @@ let StructBase = Class("StructBase", Array, {
|
||||
}
|
||||
});
|
||||
|
||||
const Timer = Class("Timer", {
|
||||
var Timer = Class("Timer", {
|
||||
init: function (minInterval, maxInterval, callback) {
|
||||
this._timer = services.Timer();
|
||||
this.callback = callback;
|
||||
@@ -1056,7 +1095,7 @@ function octal(decimal) parseInt(decimal, 8);
|
||||
/**
|
||||
* Array utility methods.
|
||||
*/
|
||||
const array = Class("array", Array, {
|
||||
var array = Class("array", Array, {
|
||||
init: function (ary) {
|
||||
if (isinstance(ary, ["Iterator", "Generator"]) || "__iterator__" in ary)
|
||||
ary = [k for (k in ary)];
|
||||
|
||||
@@ -10,8 +10,8 @@ defineModule("bookmarkcache", {
|
||||
require: ["services", "storage", "util"]
|
||||
});
|
||||
|
||||
const Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "id");
|
||||
const Keyword = Struct("keyword", "title", "icon", "url");
|
||||
var Bookmark = Struct("url", "title", "icon", "post", "keyword", "tags", "id");
|
||||
var Keyword = Struct("keyword", "title", "icon", "url");
|
||||
Bookmark.defaultValue("icon", function () BookmarkCache.getFavicon(this.url));
|
||||
Bookmark.setter = function (key, func) this.prototype.__defineSetter__(key, func);
|
||||
Bookmark.prototype.__defineGetter__("extra", function () [
|
||||
@@ -33,9 +33,9 @@ Bookmark.setter("tags", function (val) {
|
||||
services.tagging.tagURI(this.uri, val);
|
||||
});
|
||||
|
||||
const name = "bookmark-cache";
|
||||
var name = "bookmark-cache";
|
||||
|
||||
const BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
|
||||
var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
|
||||
POST: "bookmarkProperties/POSTData",
|
||||
|
||||
init: function init() {
|
||||
|
||||
@@ -11,7 +11,7 @@ defineModule("highlight", {
|
||||
use: ["template", "util"]
|
||||
});
|
||||
|
||||
const Highlight = Struct("class", "selector", "sites",
|
||||
var Highlight = Struct("class", "selector", "sites",
|
||||
"default", "value", "agent",
|
||||
"base", "baseClass", "style");
|
||||
Highlight.liveProperty = function (name, prop) {
|
||||
@@ -52,7 +52,7 @@ Highlight.prototype.toString = function ()
|
||||
*
|
||||
* @author Kris Maglione <maglione.k@gmail.com>
|
||||
*/
|
||||
const Highlights = Module("Highlight", {
|
||||
var Highlights = Module("Highlight", {
|
||||
init: function () {
|
||||
this.highlight = {};
|
||||
this.loaded = {};
|
||||
|
||||
@@ -13,7 +13,7 @@ defineModule("prefs", {
|
||||
use: ["template"]
|
||||
});
|
||||
|
||||
const Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
SAVED: "extensions.dactyl.saved.",
|
||||
RESTORE: "extensions.dactyl.restore.",
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ let tmp = {};
|
||||
services.subscriptLoader.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
tmp.Sanitizer.prototype.__proto__ = Class.prototype;
|
||||
|
||||
const Range = Struct("min", "max");
|
||||
var Range = Struct("min", "max");
|
||||
Range.prototype.contains = function (date)
|
||||
date == null || (this.min == null || date >= this.min) && (this.max == null || date <= this.max);
|
||||
Range.prototype.__defineGetter__("isEternity", function () this.max == null && this.min == null);
|
||||
@@ -33,7 +33,7 @@ Range.prototype.__defineGetter__("native", function ()
|
||||
this.isEternity ? null : [range.min || 0, range.max == null ? Number.MAX_VALUE : range.max]);
|
||||
|
||||
|
||||
const Item = Class("Item", {
|
||||
var Item = Class("Item", {
|
||||
init: function (name) {
|
||||
this.name = name;
|
||||
},
|
||||
@@ -55,7 +55,7 @@ const Item = Class("Item", {
|
||||
SHUTDOWN_BRANCH: "privacy.clearOnShutdown."
|
||||
});
|
||||
|
||||
const Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference], tmp.Sanitizer), {
|
||||
var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference], tmp.Sanitizer), {
|
||||
sessionStart: Date.now() * 1000,
|
||||
|
||||
init: function () {
|
||||
|
||||
@@ -14,7 +14,7 @@ defineModule("services", {
|
||||
/**
|
||||
* A lazily-instantiated XPCOM class and service cache.
|
||||
*/
|
||||
const Services = Module("Services", {
|
||||
var Services = Module("Services", {
|
||||
init: function () {
|
||||
this.classes = {};
|
||||
this.services = {};
|
||||
@@ -36,6 +36,7 @@ const Services = Module("Services", {
|
||||
this.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
|
||||
this.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
|
||||
this.add("focus", "@mozilla.org/focus-manager;1", Ci.nsIFocusManager);
|
||||
this.add("fuel", "@mozilla.org/fuel/application;1", Ci.fuelIApplication);
|
||||
this.add("history", "@mozilla.org/browser/global-history;2", [Ci.nsIBrowserHistory, Ci.nsIGlobalHistory3,
|
||||
Ci.nsINavHistoryService, Ci.nsPIPlacesDatabase]);
|
||||
this.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
if (this.XPCSafeJSObjectWrapper == null)
|
||||
this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
|
||||
|
||||
const myObject = Object;
|
||||
var myObject = Object;
|
||||
Components.utils.import("resource://dactyl/base.jsm");
|
||||
defineModule("storage", {
|
||||
exports: ["File", "storage"],
|
||||
require: ["services", "util"]
|
||||
});
|
||||
|
||||
const win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
var win32 = /^win(32|nt)$/i.test(services.runtime.OS);
|
||||
|
||||
function loadData(name, store, type) {
|
||||
try {
|
||||
@@ -33,7 +33,7 @@ function saveData(obj) {
|
||||
storage.infoPath.child(obj.name).write(obj.serial);
|
||||
}
|
||||
|
||||
const StoreBase = Class("StoreBase", {
|
||||
var StoreBase = Class("StoreBase", {
|
||||
OPTIONS: ["privateData", "replacer"],
|
||||
|
||||
fireEvent: function (event, arg) { storage.fireEvent(this.name, event, arg); },
|
||||
@@ -61,7 +61,7 @@ const StoreBase = Class("StoreBase", {
|
||||
save: function () { saveData(this); },
|
||||
});
|
||||
|
||||
const ArrayStore = Class("ArrayStore", StoreBase, {
|
||||
var ArrayStore = Class("ArrayStore", StoreBase, {
|
||||
_constructor: Array,
|
||||
|
||||
get length() this._object.length,
|
||||
@@ -107,7 +107,7 @@ const ArrayStore = Class("ArrayStore", StoreBase, {
|
||||
__iterator__: function () Iterator(this._object),
|
||||
});
|
||||
|
||||
const ObjectStore = Class("ObjectStore", StoreBase, {
|
||||
var ObjectStore = Class("ObjectStore", StoreBase, {
|
||||
_constructor: myObject,
|
||||
|
||||
clear: function () {
|
||||
@@ -142,7 +142,7 @@ const ObjectStore = Class("ObjectStore", StoreBase, {
|
||||
__iterator__: function () Iterator(this._object),
|
||||
});
|
||||
|
||||
const Storage = Module("Storage", {
|
||||
var Storage = Module("Storage", {
|
||||
alwaysReload: {},
|
||||
|
||||
init: function () {
|
||||
@@ -269,7 +269,7 @@ const Storage = Module("Storage", {
|
||||
* @param {boolean} checkPWD Whether to allow expansion relative to the
|
||||
* current directory. @default true
|
||||
*/
|
||||
const File = Class("File", {
|
||||
var File = Class("File", {
|
||||
init: function (path, checkPWD) {
|
||||
let file = services.File();
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ defineModule("styles", {
|
||||
});
|
||||
|
||||
function cssUri(css) "chrome-data:text/css," + encodeURI(css);
|
||||
const namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||
var namespace = "@namespace html " + XHTML.uri.quote() + ";\n" +
|
||||
"@namespace xul " + XUL.uri.quote() + ";\n" +
|
||||
"@namespace dactyl " + NS.uri.quote() + ";\n";
|
||||
|
||||
const Sheet = Struct("name", "id", "sites", "css", "hive", "agent");
|
||||
var Sheet = Struct("name", "id", "sites", "css", "hive", "agent");
|
||||
Sheet.liveProperty = function (name) {
|
||||
let i = this.prototype.members[name];
|
||||
this.prototype.__defineGetter__(name, function () this[i]);
|
||||
@@ -73,7 +73,7 @@ update(Sheet.prototype, {
|
||||
}
|
||||
});
|
||||
|
||||
const Hive = Class("Hive", {
|
||||
var Hive = Class("Hive", {
|
||||
init: function () {
|
||||
this.sheets = [];
|
||||
this.names = {};
|
||||
@@ -212,7 +212,7 @@ const Hive = Class("Hive", {
|
||||
*
|
||||
* @author Kris Maglione <maglione.k@gmail.com>
|
||||
*/
|
||||
const Styles = Module("Styles", {
|
||||
var Styles = Module("Styles", {
|
||||
init: function () {
|
||||
this._id = 0;
|
||||
this.user = Hive();
|
||||
|
||||
@@ -13,7 +13,7 @@ defineModule("template", {
|
||||
|
||||
default xml namespace = XHTML;
|
||||
|
||||
const Template = Module("Template", {
|
||||
var Template = Module("Template", {
|
||||
add: function add(a, b) a + b,
|
||||
join: function join(c) function (a, b) a + c + b,
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ defineModule("util", {
|
||||
use: ["highlight", "storage", "template"]
|
||||
});
|
||||
|
||||
const XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
||||
const XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
||||
const XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
const NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator");
|
||||
var XBL = Namespace("xbl", "http://www.mozilla.org/xbl");
|
||||
var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml");
|
||||
var XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
var NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator");
|
||||
default xml namespace = XHTML;
|
||||
|
||||
memoize(this, "Commands", function () {
|
||||
@@ -28,7 +28,7 @@ memoize(this, "Commands", function () {
|
||||
return obj.Commands;
|
||||
});
|
||||
|
||||
const FailedAssertion = Class("FailedAssertion", ErrorBase);
|
||||
var FailedAssertion = Class("FailedAssertion", ErrorBase);
|
||||
|
||||
function wrapCallback(fn)
|
||||
fn.wrapper = function wrappedCallback () {
|
||||
@@ -41,7 +41,7 @@ function wrapCallback(fn)
|
||||
}
|
||||
}
|
||||
|
||||
const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), {
|
||||
init: function () {
|
||||
this.Array = array;
|
||||
|
||||
@@ -92,16 +92,17 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* @param {object} obj
|
||||
*/
|
||||
addObserver: function (obj) {
|
||||
let observers = obj.observe;
|
||||
let observers = obj._observe || obj.observe;
|
||||
obj._observe = observers;
|
||||
function register(meth) {
|
||||
services.observer[meth](obj, "quit-application", true);
|
||||
services.observer[meth](obj, "dactyl-unload", true);
|
||||
services.observer[meth](obj, "dactyl-cleanup", true);
|
||||
for (let target in keys(observers))
|
||||
services.observer[meth](obj, target, true);
|
||||
}
|
||||
Class.replaceProperty(obj, "observe",
|
||||
function (subject, target, data) {
|
||||
if (target == "quit-application" || target == "dactyl-unload")
|
||||
if (target == "quit-application" || target == "dactyl-cleanup")
|
||||
register("removeObserver");
|
||||
if (observers[target])
|
||||
observers[target].call(obj, subject, data);
|
||||
@@ -1402,7 +1403,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
||||
* Math utility methods.
|
||||
* @singleton
|
||||
*/
|
||||
const GlobalMath = Math;
|
||||
var GlobalMath = Math;
|
||||
var Math = update(Object.create(GlobalMath), {
|
||||
/**
|
||||
* Returns the specified *value* constrained to the range *min* - *max*.
|
||||
|
||||
Reference in New Issue
Block a user