diff --git a/common/content/commandline.js b/common/content/commandline.js index eb414c9f..3498ca1b 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -244,11 +244,18 @@ const CommandWidgets = Class("CommandWidgets", { completionList: Class.memoize(function () document.getElementById("dactyl-completions")), completionContainer: Class.memoize(function () this.completionList.parentNode), multilineOutput: Class.memoize(function () { - let elem = document.getElementById("dactyl-multiline-output"); + this.__defineGetter__("multilineOutput", function () { + let elem = document.getElementById("dactyl-multiline-output"); + while (elem.contentDocument.documentURI != elem.getAttribute("src") || + ["viewable", "complete"].indexOf(elem.contentDocument.readyState) < 0) + util.threadYield(); + return elem; + }); + + let elem = this.multilineOutput; elem.contentWindow.addEventListener("unload", function (event) { event.preventDefault(); }, true); - elem.contentWindow.addEventListener("load", function (event) { - elem.contentDocument.body.id = "dactyl-multiline-output-content"; - }, false); + elem.contentDocument.body.id = "dactyl-multiline-output-content"; + ["copy", "copylink", "selectall"].forEach(function (tail) { // some host apps use "hostPrefixContext-copy" ids let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]"; @@ -525,7 +532,7 @@ const CommandLine = Module("commandline", { set: function (value) { this.widgets.multilineInput.collapsed = !value; } }), multilineOutputVisible: Modes.boundProperty({ - set: function (value) { this.widgets.mowContainer.collapsed = !value; } + set: function (value) { (this.widgets.mowContainer || {}).collapsed = !value; } }), /** diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 1073d8bc..8a5c6471 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -97,16 +97,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); @@ -918,19 +919,11 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]) module.cleanup(); services.observer.addObserver(this, "dactyl-rehash", true); - - /* - let getOwnPropertyNames = Object.getOwnPropertyNames; - for each (let global in defineModule.globals.reverse()) - for each (let k in getOwnPropertyNames(global)) - try { - delete global[k]; - } - catch (e) {} - */ }); }, "dactyl-rehash": function () { + services.observer.removeObserver(this, "dactyl-rehash"); + util.dump("dactyl: util: observe: dactyl-rehash"); for (let module in values(defineModule.modules)) { util.dump("dactyl: util: init(" + module + ")");