From: Michael Schutte Date: Tue, 7 May 2013 09:39:55 +0000 (+0200) Subject: Import r6923 from upstream hg supporting Firefox up to 22.0a1 X-Git-Tag: upstream/1.0+hg6924~1 X-Git-Url: https://git.donarmstrong.com/?p=dactyl.git;a=commitdiff_plain;h=8b6fcae7eaa413bc62d645d2d0c99835c47265e6 Import r6923 from upstream hg supporting Firefox up to 22.0a1 --- diff --git a/.hg_archival.txt b/.hg_archival.txt index 8260397..f8dc1a2 100644 --- a/.hg_archival.txt +++ b/.hg_archival.txt @@ -1,4 +1,5 @@ repo: 373f1649c80dea9be7b5bc9c57e8395f94f93ab1 -node: 227d1399fe7c9d8de98fc6ab3222cf9e1d8ad38f -branch: pentadactyl-1.0-branch -tag: pentadactyl-1.0 +node: 6d61fc0f8f2757c919fb4bb29dfed28df23b5030 +branch: default +latesttag: pentadactyl-1.0rc1 +latesttagdistance: 194 diff --git a/.hgignore b/.hgignore deleted file mode 100644 index fcc3ad8..0000000 --- a/.hgignore +++ /dev/null @@ -1,43 +0,0 @@ -## To see if new rules exclude any existing files, run -## -## hg status -i -## -## after modifying this file. - -syntax: glob - -## Generated by the build process -*.xpi -*.o -*.so -*.xpt -*/.depend -*/config.local.mk -*/locale/*/*.html -*/chrome -*/contrib/vim/*.vba -*/bak/* -downloads/* -.git/* - -binary/src/*/*.h - -common/tests/functional/log - -*.py[co] - -## Editor backup and swap files -*~ -.#* -\#**\# -.*.sw[op] -.sw[op] - -## Generated by Mac filesystem -.DS_Store - -syntax: regexp - -## For rejects -\.(orig|rej|bak|diff)$ - diff --git a/.hgsub b/.hgsub deleted file mode 100644 index 2ee5d68..0000000 --- a/.hgsub +++ /dev/null @@ -1 +0,0 @@ -binary/components = https://code.google.com/p/dactyl.binary-modules/ diff --git a/.hgsubstate b/.hgsubstate deleted file mode 100644 index 9d9a838..0000000 --- a/.hgsubstate +++ /dev/null @@ -1 +0,0 @@ -9f8a25e7d9861892d8e6136764bb88139e0a7253 binary/components diff --git a/README.E4X b/README.E4X deleted file mode 100644 index 5e0b8a9..0000000 --- a/README.E4X +++ /dev/null @@ -1,149 +0,0 @@ - A terse introduction to E4X - Public Domain - -The inline XML literals in this code are part of E4X, a standard -XML processing interface for ECMAScript. In addition to syntax -for XML literals, E4X provides a new kind of native object, -"xml", and a syntax, similar to XPath, for accessing and -modifying the tree. Here is a brief synopsis of the kind of -usage you'll see herein: - -> let xml = - - - - - - ; - - // Select all bar elements of the root foo element -> xml.bar - - - // Select all baz elements anywhere beneath the root -> xml..baz - - - - // Select all of the immediate children of the root -> xml.* - - - - // Select the bar attribute of the root node -> xml.@bar - baz - - // Select all id attributes in the tree -> xml..@id - 1 - 2 - - // Select all attributes of the root node -> xml.@* - baz - quz - -// Add a quux elemend beneath the first baz -> xml..baz[0] += - - -> xml - - - - - - - - - // and beneath the second -> xml.baz[1] = -> xml - - - - - - - - - - // Replace bar's subtree with a foo element -> xml.bar.* = -> xml - - - - - - - - - // Add a bar below bar -> xml.bar.* += - - -> xml - - - - - - - - - - // Adding a quux attribute to the root -> xml.@quux = "foo" - foo -> xml - - - - - - - - - -> xml.bar.@id = "0" -> xml..foo[0] = "Foo" - Foo -> xml..bar[1] = "Bar" - Bar -> xml -js> xml - - - Foo - Bar - - - - - - // Selecting all bar elements where id="1" -> xml..bar.(@id == 1) - Bar - - // Literals: - // XMLList literal. No root node. -> <>Foo
Baz - Foo -
- Baz - -// Interpolation. -> let x = "" -> {x + ""} - -> {x + ""}.toXMLString() - <foo/><?> - -> let x = -> {x}.toXMLString() - - - - diff --git a/common/bootstrap.js b/common/bootstrap.js index d81411e..d0dd98a 100755 --- a/common/bootstrap.js +++ b/common/bootstrap.js @@ -5,77 +5,317 @@ // // See https://wiki.mozilla.org/Extension_Manager:Bootstrapped_Extensions // for details. +"use strict"; -const NAME = "bootstrap"; const global = this; var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; -function module(uri) { - let obj = {}; - Cu.import(uri, obj); - return obj; -} +function module(uri) Cu.import(uri, {}); + +const DEBUG = true; + +__defineGetter__("BOOTSTRAP", function () "resource://" + moduleName + "/bootstrap.jsm"); -const { AddonManager } = module("resource://gre/modules/AddonManager.jsm"); -const { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm"); -const { Services } = module("resource://gre/modules/Services.jsm"); +var { AddonManager } = module("resource://gre/modules/AddonManager.jsm"); +var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm"); +var { Services } = module("resource://gre/modules/Services.jsm"); const resourceProto = Services.io.getProtocolHandler("resource") .QueryInterface(Ci.nsIResProtocolHandler); const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager); const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); -const DISABLE_ACR = "resource://dactyl-content/disable-acr.jsm"; -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("\n" + name + ": bootstrap: " + e + "\n" + (e.stack || Error().stack) + "\n"); + let stack = e.stack || Error().stack; + dump("\n" + name + ": bootstrap: " + e + "\n" + stack + "\n"); Cu.reportError(e); + Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService) + .logStringMessage(stack); } -function debug(msg) { - dump(name + ": " + msg + "\n"); +function debug() { + if (DEBUG) + dump(name + ": " + Array.join(arguments, ", ") + "\n"); } -function httpGet(url) { +function httpGet(uri) { let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest); xmlhttp.overrideMimeType("text/plain"); - xmlhttp.open("GET", url, false); + xmlhttp.open("GET", uri.spec || uri, false); xmlhttp.send(null); return xmlhttp; } +let moduleName; let initialized = false; let addon = null; let addonData = null; let basePath = null; +let bootstrap; +let bootstrap_jsm; let categories = []; let components = {}; let resources = []; let getURI = null; -function updateLoader() { +let JSMLoader = { + SANDBOX: Cu.nukeSandbox && false, + + get addon() addon, + + currentModule: null, + + factories: [], + + get name() name, + + get module() moduleName, + + globals: {}, + modules: {}, + + times: { + all: 0, + add: function add(major, minor, delta) { + this.all += delta; + + this[major] = (this[major] || 0) + delta; + if (minor) { + minor = ":" + minor; + this[minor] = (this[minor] || 0) + delta; + this[major + minor] = (this[major + minor] || 0) + delta; + } + }, + clear: function clear() { + for (let key in this) + if (typeof this[key] !== "number") + delete this[key]; + } + }, + + getTarget: function getTarget(url) { + let uri = Services.io.newURI(url, null, null); + if (uri.schemeIs("resource")) + return resourceProto.resolveURI(uri); + + let chan = Services.io.newChannelFromURI(uri); + try { chan.cancel(Cr.NS_BINDING_ABORTED) } catch (e) {} + return chan.name; + }, + + _atexit: [], + + atexit: function atexit(arg, self) { + if (typeof arg !== "string") + this._atexit.push(arguments); + else + for each (let [fn, self] in this._atexit) + try { + fn.call(self, arg); + } + catch (e) { + reportError(e); + } + }, + + _load: function _load(name, target) { + let urls = [name]; + if (name.indexOf(":") === -1) + urls = this.config["module-paths"].map(function (path) path + name + ".jsm"); + + for each (let url in urls) + try { + var uri = this.getTarget(url); + if (uri in this.globals) + return this.modules[name] = this.globals[uri]; + + this.globals[uri] = this.modules[name]; + bootstrap_jsm.loadSubScript(url, this.modules[name]); + return; + } + catch (e) { + debug("Loading " + name + ": " + e); + delete this.globals[uri]; + + if (typeof e != "string") + throw e; + } + + throw Error("No such module: " + name); + }, + + load: function load(name, target) { + if (!this.modules.hasOwnProperty(name)) { + this.modules[name] = this.modules.base ? bootstrap.create(this.modules.base) + : bootstrap.import({ JSMLoader: this, module: global.module }); + + let currentModule = this.currentModule; + this.currentModule = this.modules[name]; + + try { + this._load(name, this.modules[name]); + } + catch (e) { + delete this.modules[name]; + reportError(e); + throw e; + } + finally { + this.currentModule = currentModule; + } + } + + let module = this.modules[name]; + if (target) + for each (let symbol in module.EXPORTED_SYMBOLS) + target[symbol] = module[symbol]; + + return module; + }, + + // Cuts down on stupid, fscking url mangling. + get loadSubScript() bootstrap_jsm.loadSubScript, + + cleanup: function unregister() { + for each (let factory in this.factories.splice(0)) + manager.unregisterFactory(factory.classID, factory); + }, + + Factory: function Factory(class_) ({ + __proto__: class_.prototype, + + createInstance: function (outer, iid) { + try { + if (outer != null) + throw Cr.NS_ERROR_NO_AGGREGATION; + if (!class_.instance) + class_.instance = new class_(); + return class_.instance.QueryInterface(iid); + } + catch (e) { + Cu.reportError(e); + throw e; + } + } + }), + + registerFactory: function registerFactory(factory) { + manager.registerFactory(factory.classID, + String(factory.classID), + factory.contractID, + factory); + this.factories.push(factory); + } +}; + +function init() { + debug("bootstrap: init"); + + let manifestURI = getURI("chrome.manifest"); + let manifest = httpGet(manifestURI) + .responseText + .replace(/#(resource)#/g, "$1") + .replace(/^\s*|\s*$|#.*/g, "") + .replace(/^\s*\n/gm, ""); + + for each (let line in manifest.split("\n")) { + let fields = line.split(/\s+/); + switch(fields[0]) { + case "category": + categoryManager.addCategoryEntry(fields[1], fields[2], fields[3], false, true); + categories.push([fields[1], fields[2]]); + break; + case "component": + components[fields[1]] = new FactoryProxy(getURI(fields[2]).spec, fields[1]); + break; + case "contract": + components[fields[2]].contractID = fields[1]; + break; + + case "resource": + moduleName = moduleName || fields[1]; + resources.push(fields[1]); + resourceProto.setSubstitution(fields[1], getURI(fields[2])); + } + } + + JSMLoader.config = JSON.parse(httpGet("resource://dactyl-local/config.json").responseText); + + 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; + + // Flush the cache if necessary, just to be paranoid + let pref = "extensions.dactyl.cacheFlushCheck"; + let val = addon.version; + if (!Services.prefs.prefHasUserValue(pref) || Services.prefs.getCharPref(pref) != val) { + var cacheFlush = true; + Services.obs.notifyObservers(null, "startupcache-invalidate", ""); + Services.prefs.setCharPref(pref, val); + } + try { - JSMLoader.loader = Cc["@dactyl.googlecode.com/extra/utils"].getService(Ci.dactylIUtils); + //JSMLoader.load("disable-acr").init(addon.id); + } + catch (e) { + reportError(e); } - catch (e) {}; + + Services.obs.notifyObservers(null, "dactyl-rehash", null); + + JSMLoader.bootstrap = global; + + JSMLoader.load("config", global); + JSMLoader.load("main", global); + + JSMLoader.cacheFlush = cacheFlush; + JSMLoader.load("base", global); + + if (!(BOOTSTRAP_CONTRACT in Cc)) { + // Use Sandbox to prevent closures over this scope + let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance()); + let factory = Cu.evalInSandbox("({ createInstance: function () this })", sandbox); + + factory.classID = Components.ID("{f541c8b0-fe26-4621-a30b-e77d21721fb5}"); + factory.contractID = BOOTSTRAP_CONTRACT; + factory.QueryInterface = XPCOMUtils.generateQI([Ci.nsIFactory]); + factory.wrappedJSObject = factory; + + manager.registerFactory(factory.classID, String(factory.classID), + BOOTSTRAP_CONTRACT, factory); + } + + Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader = !Cu.unload && JSMLoader; + + for each (let component in components) + component.register(); + + updateVersion(); + + if (addon !== addonData) + require("main", global); } /** * Performs necessary migrations after a version change. */ function updateVersion() { + function isDev(ver) /^hg|pre$/.test(ver); try { - function isDev(ver) /^hg|pre$/.test(ver); if (typeof require === "undefined" || addon === addonData) return; - require(global, "config"); - require(global, "prefs"); + JSMLoader.load("prefs", global); config.lastVersion = localPrefs.get("lastVersion", null); localPrefs.set("lastVersion", addon.version); @@ -100,7 +340,7 @@ function startup(data, reason) { if (!initialized) { initialized = true; - debug("bootstrap: init" + " " + data.id); + debug("bootstrap: init " + data.id); addonData = data; addon = data; @@ -108,10 +348,9 @@ function startup(data, reason) { AddonManager.getAddonByID(addon.id, function (a) { addon = a; - updateLoader(); updateVersion(); if (typeof require !== "undefined") - require(global, "main"); + require("main", global); }); if (basePath.isDirectory()) @@ -166,120 +405,13 @@ FactoryProxy.prototype = { } } -function init() { - debug("bootstrap: init"); - - let manifestURI = getURI("chrome.manifest"); - let manifest = httpGet(manifestURI.spec) - .responseText - .replace(/^\s*|\s*$|#.*/g, "") - .replace(/^\s*\n/gm, ""); - - let suffix = "-"; - let chars = "0123456789abcdefghijklmnopqrstuv"; - for (let n = Date.now(); n; n = Math.round(n / chars.length)) - suffix += chars[n % chars.length]; - - for each (let line in manifest.split("\n")) { - let fields = line.split(/\s+/); - switch(fields[0]) { - case "category": - categoryManager.addCategoryEntry(fields[1], fields[2], fields[3], false, true); - categories.push([fields[1], fields[2]]); - break; - case "component": - components[fields[1]] = new FactoryProxy(getURI(fields[2]).spec, fields[1]); - break; - case "contract": - components[fields[2]].contractID = fields[1]; - break; - - case "resource": - resources.push(fields[1], fields[1] + suffix); - resourceProto.setSubstitution(fields[1], getURI(fields[2])); - resourceProto.setSubstitution(fields[1] + suffix, getURI(fields[2])); - } - } - - // Flush the cache if necessary, just to be paranoid - let pref = "extensions.dactyl.cacheFlushCheck"; - let val = addon.version; - if (!Services.prefs.prefHasUserValue(pref) || Services.prefs.getCharPref(pref) != val) { - var cacheFlush = true; - Services.obs.notifyObservers(null, "startupcache-invalidate", ""); - Services.prefs.setCharPref(pref, val); - } - - try { - module(DISABLE_ACR).init(addon.id); - } - catch (e) { - reportError(e); - } - - if (JSMLoader) { - // Temporary hacks until platforms and dactyl releases that don't - // support Cu.unload are phased out. - if (Cu.unload) { - // Upgrading from dactyl release without Cu.unload support. - Cu.unload(BOOTSTRAP_JSM); - for (let [name] in Iterator(JSMLoader.globals)) - Cu.unload(~name.indexOf(":") ? name : "resource://dactyl" + JSMLoader.suffix + "/" + name); - } - else if (JSMLoader.bump != 6) { - // We're in a version without Cu.unload support and the - // JSMLoader interface has changed. Bump off the old one. - Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm", - Cu.import(BOOTSTRAP_JSM, global)); - } - } - - if (!JSMLoader || JSMLoader.bump !== 6 || Cu.unload) - Cu.import(BOOTSTRAP_JSM, global); - - JSMLoader.name = name; - JSMLoader.bootstrap = this; - - JSMLoader.load(BOOTSTRAP_JSM, global); - - JSMLoader.init(suffix); - JSMLoader.cacheFlush = cacheFlush; - JSMLoader.load("base.jsm", global); - - if (!(BOOTSTRAP_CONTRACT in Cc)) { - // Use Sandbox to prevent closures over this scope - let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].getService()); - let factory = Cu.evalInSandbox("({ createInstance: function () this })", sandbox); - - factory.classID = Components.ID("{f541c8b0-fe26-4621-a30b-e77d21721fb5}"); - factory.contractID = BOOTSTRAP_CONTRACT; - factory.QueryInterface = XPCOMUtils.generateQI([Ci.nsIFactory]); - factory.wrappedJSObject = factory; - - manager.registerFactory(factory.classID, String(factory.classID), - BOOTSTRAP_CONTRACT, factory); - } - - Cc[BOOTSTRAP_CONTRACT].getService().wrappedJSObject.loader = !Cu.unload && JSMLoader; - - for each (let component in components) - component.register(); - - Services.obs.notifyObservers(null, "dactyl-rehash", null); - updateVersion(); - - updateLoader(); - if (addon !== addonData) - require(global, "main"); -} - function shutdown(data, reason) { - debug("bootstrap: shutdown " + reasonToString(reason)); + let strReason = reasonToString(reason); + debug("bootstrap: shutdown " + strReason); + if (reason != APP_SHUTDOWN) { try { - module(DISABLE_ACR).cleanup(); - if (Cu.unload) - Cu.unload(DISABLE_ACR); + //JSMLoader.load("disable-acr").cleanup(addon.id); } catch (e) { reportError(e); @@ -288,10 +420,19 @@ function shutdown(data, reason) { if (~[ADDON_UPGRADE, ADDON_DOWNGRADE, ADDON_UNINSTALL].indexOf(reason)) Services.obs.notifyObservers(null, "dactyl-purge", null); - Services.obs.notifyObservers(null, "dactyl-cleanup", reasonToString(reason)); + Services.obs.notifyObservers(null, "dactyl-cleanup", strReason); Services.obs.notifyObservers(null, "dactyl-cleanup-modules", reasonToString(reason)); - JSMLoader.purge(); + JSMLoader.atexit(strReason); + JSMLoader.cleanup(strReason); + + if (JSMLoader.SANDBOX) + Cu.nukeSandbox(bootstrap); + bootstrap_jsm.require = null; + Cu.unload(BOOTSTRAP); + bootstrap = null; + bootstrap_jsm = null; + for each (let [category, entry] in categories) categoryManager.deleteCategoryEntry(category, entry, false); for each (let resource in resources) diff --git a/common/chrome.manifest b/common/chrome.manifest index 3eae8e1..fbf9096 100644 --- a/common/chrome.manifest +++ b/common/chrome.manifest @@ -1,14 +1,14 @@ -resource dactyl-local ./ -resource dactyl-local-content content/ -resource dactyl-local-skin skin/ -resource dactyl-local-locale locale/ - -resource dactyl-common ../common/ resource dactyl ../common/modules/ +resource dactyl-common ../common/ resource dactyl-content ../common/content/ resource dactyl-skin ../common/skin/ resource dactyl-locale ../common/locale/ +resource dactyl-local ./ +resource dactyl-local-content content/ +resource dactyl-local-skin skin/ +resource dactyl-local-locale locale/ + content dactyl ../common/content/ component {16dc34f7-6d22-4aa4-a67f-2921fb5dcb69} components/commandline-handler.js diff --git a/common/components/commandline-handler.js b/common/components/commandline-handler.js index 738e275..0be89de 100644 --- a/common/components/commandline-handler.js +++ b/common/components/commandline-handler.js @@ -17,11 +17,8 @@ Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); function init() { Cu.import("resource://dactyl/bootstrap.jsm"); - if (!JSMLoader.initialized) - JSMLoader.init(); - JSMLoader.load("base.jsm", global); - require(global, "config"); - require(global, "util"); + require("config", global); + require("util", global); } function CommandLineHandler() { diff --git a/common/content/abbreviations.js b/common/content/abbreviations.js index 0829497..4b64644 100644 --- a/common/content/abbreviations.js +++ b/common/content/abbreviations.js @@ -1,10 +1,10 @@ // Copyright (c) 2006-2009 by Martin Stubenschrott // Copyright (c) 2010 by anekos -// Copyright (c) 2010-2011 by Kris Maglione +// Copyright (c) 2010-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; /** @scope modules */ @@ -213,18 +213,18 @@ var Abbreviations = Module("abbreviations", { nonkeyword: /[ "']/ }; - this._match = util.regexp(<>) (+ )$ | // full-id (^ | \s | ) (+ )$ | // end-id (^ | \s ) (\S* )$ // non-id - ]]>, "x", params); - this._check = util.regexp(<>+ | // full-id + | // end-id \S* // non-id ) $ - ]]>, "x", params); + */), "x", params); }, get: deprecated("group.abbrevs.get", { get: function get() this.user.closure.get }), @@ -262,33 +262,29 @@ var Abbreviations = Module("abbreviations", { function abbrevs(hive) hive.merged.filter(function (abbr) (abbr.inModes(modes) && abbr.lhs.indexOf(lhs) == 0)); - let list = - - - - - - - { - template.map(hives, function (hive) let (i = 0) - + - template.map(abbrevs(hive), function (abbrev) - - - - - - ) + - ) - } -
- {_("title.Mode")}{_("title.Abbrev")}{_("title.Replacement")}
{!i++ ? hive.name : ""}{abbrev.modeChar}{abbrev.lhs}{abbrev.rhs}
; - - // TODO: Move this to an ItemList to show this automatically - if (list.*.length() === list.text().length() + 2) - dactyl.echomsg(_("abbreviation.none")); - else - commandline.commandOutput(list); + let list = ["table", {}, + ["tr", { highlight: "Title" }, + ["td"], + ["td", { style: "padding-right: 1em;" }, _("title.Mode")], + ["td", { style: "padding-right: 1em;" }, _("title.Abbrev")], + ["td", { style: "padding-right: 1em;" }, _("title.Replacement")]], + ["col", { style: "min-width: 6em; padding-right: 1em;" }], + hives.map(function (hive) let (i = 0) [ + ["tr", { style: "height: .5ex;" }], + abbrevs(hive).map(function (abbrev) + ["tr", {}, + ["td", { highlight: "Title" }, !i++ ? String(hive.name) : ""], + ["td", {}, abbrev.modeChar], + ["td", {}, abbrev.lhs], + ["td", {}, abbrev.rhs]]), + ["tr", { style: "height: .5ex;" }]])]; + + // FIXME? + // // TODO: Move this to an ItemList to show this automatically + // if (list.*.length() === list.text().length() + 2) + // dactyl.echomsg(_("abbreviation.none")); + // else + commandline.commandOutput(list); } }, { @@ -299,7 +295,7 @@ var Abbreviations = Module("abbreviations", { user: contexts.hives.abbrevs.user }); }, - completion: function () { + completion: function initCompletion() { completion.abbreviation = function abbreviation(context, modes, group) { group = group || abbreviations.user; let fn = modes ? function (abbr) abbr.inModes(modes) : util.identity; @@ -307,7 +303,7 @@ var Abbreviations = Module("abbreviations", { context.completions = group.merged.filter(fn); }; }, - commands: function () { + commands: function initCommands() { function addAbbreviationCommands(modes, ch, modeDescription) { modes.sort(); modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; diff --git a/common/content/about.xul b/common/content/about.xul index aba640b..7c1aa15 100644 --- a/common/content/about.xul +++ b/common/content/about.xul @@ -20,7 +20,7 @@ by Kris Maglione, Doug Kearns, et al. &dactyl.appName; is open source and freely distributable type :q<Enter> to exit -type :help<Enter> or <F1> for on-line help +type :help<Enter> for on-line help type :help faq<Enter> for the FAQ page type :help versions<Enter> for version info diff --git a/common/content/autocommands.js b/common/content/autocommands.js index 31c3ad9..b141902 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -1,10 +1,10 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; /** @scope modules */ @@ -103,31 +103,28 @@ var AutoCommands = Module("autocommands", { return cmds; } - XML.prettyPrinting = XML.ignoreWhitespace = false; - commandline.commandOutput( - - - - - { - template.map(hives, function (hive) - - - + - + - template.map(cmds(hive), function ([event, items]) - + - template.map(items, function (item, i) - - - - - ) + - ) + - ) - } -
----- Auto Commands -----
{hive.name} - {hive.filter}
{i == 0 ? event : ""}{item.filter.toXML ? item.filter.toXML() : item.filter}{item.command}
); + let table = ( + ["table", {}, + ["tr", { highlight: "Title" }, + ["td", { colspan: "3" }, "----- Auto Commands -----"]], + hives.map(function (hive) [ + ["tr", {}, + ["td", { colspan: "3" }, + ["span", { highlight: "Title" }, hive.name], + " ", hive.filter.toJSONXML(modules)]], + ["tr", { style: "height: .5ex;" }], + iter(cmds(hive)).map(function ([event, items]) [ + ["tr", { style: "height: .5ex;" }], + items.map(function (item, i) + ["tr", {}, + ["td", { highlight: "Title", style: "padding-left: 1em; padding-right: 1em;" }, + i == 0 ? event : ""], + ["td", {}, item.filter.toJSONXML ? item.filter.toJSONXML(modules) : String(item.filter)], + ["td", {}, String(item.command)]]), + ["tr", { style: "height: .5ex;" }]]).toArray(), + ["tr", { style: "height: .5ex;" }], + ])]); + commandline.commandOutput(table); }, /** @@ -168,7 +165,7 @@ var AutoCommands = Module("autocommands", { } }, { }, { - contexts: function () { + contexts: function initContexts() { update(AutoCommands.prototype, { hives: contexts.Hives("autocmd", AutoCmdHive), user: contexts.hives.autocmd.user, @@ -176,7 +173,7 @@ var AutoCommands = Module("autocommands", { matchingHives: function matchingHives(uri, doc) contexts.matchingGroups(uri, doc).autocmd }); }, - commands: function () { + commands: function initCommands() { commands.add(["au[tocmd]"], "Execute commands automatically on events", function (args) { @@ -280,15 +277,15 @@ var AutoCommands = Module("autocommands", { }); }); }, - completion: function () { + completion: function initCompletion() { completion.autocmdEvent = function autocmdEvent(context) { context.completions = Iterator(config.autocommands); }; }, - javascript: function () { + javascript: function initJavascript() { JavaScript.setCompleter(AutoCmdHive.prototype.get, [function () Iterator(config.autocommands)]); }, - options: function () { + options: function initOptions() { options.add(["eventignore", "ei"], "List of autocommand event names which should be ignored", "stringlist", "", diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 195bee6..65ec115 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -1,10 +1,10 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; // also includes methods for dealing with keywords and search engines var Bookmarks = Module("bookmarks", { @@ -135,7 +135,7 @@ var Bookmarks = Module("bookmarks", { checkBookmarked: function checkBookmarked(uri) { if (PlacesUtils.asyncGetBookmarkIds) - PlacesUtils.asyncGetBookmarkIds(uri, function (ids) { + PlacesUtils.asyncGetBookmarkIds(uri, function withBookmarkIDs(ids) { statusline.bookmarked = ids.length; }); else @@ -402,7 +402,7 @@ var Bookmarks = Module("bookmarks", { } }, { }, { - commands: function () { + commands: function initCommands() { // TODO: Clean this up. const tags = { names: ["-tags", "-T"], @@ -565,7 +565,7 @@ var Bookmarks = Module("bookmarks", { privateData: true }); }, - mappings: function () { + mappings: function initMappings() { var myModes = config.browserModes; mappings.add(myModes, ["a"], @@ -605,7 +605,7 @@ var Bookmarks = Module("bookmarks", { "Toggle bookmarked state of current URL", function () { bookmarks.toggle(buffer.uri.spec); }); }, - options: function () { + options: function initOptions() { options.add(["defsearch", "ds"], "The default search engine", "string", "google", @@ -622,7 +622,7 @@ var Bookmarks = Module("bookmarks", { { completer: function completer(context) completion.searchEngine(context, true), }); }, - completion: function () { + completion: function initCompletion() { completion.bookmark = function bookmark(context, tags, extra) { context.title = ["Bookmark", "Title"]; context.format = bookmarks.format; diff --git a/common/content/browser.js b/common/content/browser.js index cc504ff..a1b1110 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -1,10 +1,10 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; /** @scope modules */ @@ -202,11 +202,11 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), commands.add(["redr[aw]"], "Redraw the screen", function () { - window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils) - .redraw(); statusline.overLink = null; statusline.updateStatus(); commandline.clear(); + window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils) + .redraw(); }, { argCount: "0" }); }, @@ -267,12 +267,12 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), mappings.add([modes.NORMAL], ["", "gh"], "Open homepage", - function () { BrowserHome(); }); + function () { window.BrowserHome(); }); mappings.add([modes.NORMAL], ["", "gH"], "Open homepage in a new tab", function () { - let homepages = gHomeButton.getHomePage(); + let homepages = window.gHomeButton.getHomePage(); dactyl.open(homepages, { from: "homepage", where: dactyl.NEW_TAB }); }); diff --git a/common/content/commandline.js b/common/content/commandline.js index c318759..f01cbb0 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -1,10 +1,10 @@ // Copyright (c) 2006-2008 by Martin Stubenschrott // Copyright (c) 2007-2011 by Doug Kearns -// Copyright (c) 2008-2011 by Kris Maglione +// Copyright (c) 2008-2012 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; /** @scope modules */ @@ -14,56 +14,47 @@ var CommandWidgets = Class("CommandWidgets", { init: function init() { let s = "dactyl-statusline-field-"; - XML.ignoreWhitespace = true; overlay.overlayWindow(window, { objects: { eventTarget: commandline }, - append: - -