1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-04 06:44:12 +01:00

[bootstrap] Fix more reinitialization issues.

--HG--
branch : bootstrapped
This commit is contained in:
Kris Maglione
2010-12-25 06:33:58 -05:00
parent d23595aa02
commit 89ec0f4d4f
2 changed files with 18 additions and 18 deletions

View File

@@ -244,11 +244,18 @@ const CommandWidgets = Class("CommandWidgets", {
completionList: Class.memoize(function () document.getElementById("dactyl-completions")), completionList: Class.memoize(function () document.getElementById("dactyl-completions")),
completionContainer: Class.memoize(function () this.completionList.parentNode), completionContainer: Class.memoize(function () this.completionList.parentNode),
multilineOutput: Class.memoize(function () { 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("unload", function (event) { event.preventDefault(); }, true);
elem.contentWindow.addEventListener("load", function (event) { elem.contentDocument.body.id = "dactyl-multiline-output-content";
elem.contentDocument.body.id = "dactyl-multiline-output-content";
}, false);
["copy", "copylink", "selectall"].forEach(function (tail) { ["copy", "copylink", "selectall"].forEach(function (tail) {
// some host apps use "hostPrefixContext-copy" ids // some host apps use "hostPrefixContext-copy" ids
let xpath = "//xul:menuitem[contains(@id, '" + "ontext-" + tail + "') and not(starts-with(@id, 'dactyl-'))]"; 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; } set: function (value) { this.widgets.multilineInput.collapsed = !value; }
}), }),
multilineOutputVisible: Modes.boundProperty({ multilineOutputVisible: Modes.boundProperty({
set: function (value) { this.widgets.mowContainer.collapsed = !value; } set: function (value) { (this.widgets.mowContainer || {}).collapsed = !value; }
}), }),
/** /**

View File

@@ -97,16 +97,17 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* @param {object} obj * @param {object} obj
*/ */
addObserver: function (obj) { addObserver: function (obj) {
let observers = obj.observe; let observers = obj._observe || obj.observe;
obj._observe = observers;
function register(meth) { function register(meth) {
services.observer[meth](obj, "quit-application", true); 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)) for (let target in keys(observers))
services.observer[meth](obj, target, true); services.observer[meth](obj, target, true);
} }
Class.replaceProperty(obj, "observe", Class.replaceProperty(obj, "observe",
function (subject, target, data) { function (subject, target, data) {
if (target == "quit-application" || target == "dactyl-unload") if (target == "quit-application" || target == "dactyl-cleanup")
register("removeObserver"); register("removeObserver");
if (observers[target]) if (observers[target])
observers[target].call(obj, subject, data); observers[target].call(obj, subject, data);
@@ -918,19 +919,11 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
module.cleanup(); module.cleanup();
services.observer.addObserver(this, "dactyl-rehash", true); 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 () { "dactyl-rehash": function () {
services.observer.removeObserver(this, "dactyl-rehash");
util.dump("dactyl: util: observe: dactyl-rehash"); util.dump("dactyl: util: observe: dactyl-rehash");
for (let module in values(defineModule.modules)) { for (let module in values(defineModule.modules)) {
util.dump("dactyl: util: init(" + module + ")"); util.dump("dactyl: util: init(" + module + ")");