mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 04:07:59 +01:00
Fix MOW styling. Enable running cleanup code on bootstrapped disable. Re-enabling still does not work.
--HG-- branch : bootstrapped
This commit is contained in:
19
common/bootstrap.js
vendored
19
common/bootstrap.js
vendored
@@ -38,6 +38,7 @@ function writeFile(file, buf) {
|
|||||||
let initialized = false;
|
let initialized = false;
|
||||||
let addon = null;
|
let addon = null;
|
||||||
let basePath = null;
|
let basePath = null;
|
||||||
|
let components = {};
|
||||||
|
|
||||||
function startup(data, reason) {
|
function startup(data, reason) {
|
||||||
dump("dactyl: bootstrap: startup\n");
|
dump("dactyl: bootstrap: startup\n");
|
||||||
@@ -68,12 +69,16 @@ function FactoryProxy(url, classID) {
|
|||||||
}
|
}
|
||||||
FactoryProxy.prototype = {
|
FactoryProxy.prototype = {
|
||||||
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
|
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
|
||||||
init: function () {
|
register: function () {
|
||||||
manager.registerFactory(this.classID,
|
manager.registerFactory(this.classID,
|
||||||
String(this.classID),
|
String(this.classID),
|
||||||
this.contractID,
|
this.contractID,
|
||||||
this);
|
this);
|
||||||
},
|
},
|
||||||
|
unregister: function () {
|
||||||
|
manager.unregisterFactory(this.classID,
|
||||||
|
this);
|
||||||
|
},
|
||||||
get module() {
|
get module() {
|
||||||
Class.replaceProperty(this, "module", {});
|
Class.replaceProperty(this, "module", {});
|
||||||
Cu.import(this.url, this.module);
|
Cu.import(this.url, this.module);
|
||||||
@@ -96,7 +101,6 @@ function init() {
|
|||||||
function url(path) addon.getResourceURI(path).spec;
|
function url(path) addon.getResourceURI(path).spec;
|
||||||
|
|
||||||
let result = [];
|
let result = [];
|
||||||
let components = {};
|
|
||||||
|
|
||||||
for each (let line in manifest.split("\n")) {
|
for each (let line in manifest.split("\n")) {
|
||||||
let fields = line.split(/\s+/);
|
let fields = line.split(/\s+/);
|
||||||
@@ -121,7 +125,7 @@ function init() {
|
|||||||
break;
|
break;
|
||||||
case "contract":
|
case "contract":
|
||||||
components[fields[2]].contractID = fields[1];
|
components[fields[2]].contractID = fields[1];
|
||||||
components[fields[2]].init();
|
components[fields[2]].register();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "resource":
|
case "resource":
|
||||||
@@ -156,6 +160,14 @@ function init() {
|
|||||||
require(global, "overlay");
|
require(global, "overlay");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shutdown(data, reason) {
|
||||||
|
dump("dactyl: bootstrap: shutdown\n");
|
||||||
|
for (let factory in values(components))
|
||||||
|
// TODO: Categories;
|
||||||
|
factory.unregister();
|
||||||
|
services.observer.notifyObservers(null, "dactyl-cleanup", null);
|
||||||
|
}
|
||||||
|
|
||||||
function reasonToString(reason) {
|
function reasonToString(reason) {
|
||||||
for each (let name in ["disable", "downgrade", "enable",
|
for each (let name in ["disable", "downgrade", "enable",
|
||||||
"install", "shutdown", "startup",
|
"install", "shutdown", "startup",
|
||||||
@@ -166,6 +178,5 @@ function reasonToString(reason) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function install(data, reason) { dump("dactyl: bootstrap: install\n") }
|
function install(data, reason) { dump("dactyl: bootstrap: install\n") }
|
||||||
function shutdown(data, reason) { dump("dactyl: bootstrap: shutdown\n") }
|
|
||||||
function uninstall(data, reason) { dump("dactyl: bootstrap: uninstall\n") }
|
function uninstall(data, reason) { dump("dactyl: bootstrap: uninstall\n") }
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,9 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
multilineOutput: Class.memoize(function () {
|
multilineOutput: Class.memoize(function () {
|
||||||
let elem = document.getElementById("dactyl-multiline-output");
|
let elem = document.getElementById("dactyl-multiline-output");
|
||||||
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-'))]";
|
||||||
|
|||||||
@@ -946,16 +946,15 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
overlay("append", function (elem, dom) elem.appendChild(dom));
|
overlay("append", function (elem, dom) elem.appendChild(dom));
|
||||||
overlay("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
|
overlay("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
|
||||||
if (obj.init)
|
if (obj.init)
|
||||||
obj.init(window, window.document.dactylDOMLoaded);
|
obj.init(window);
|
||||||
|
|
||||||
if (obj.load)
|
if (obj.load)
|
||||||
if (doc.dactylLoaded)
|
if (doc.readyState === "complete")
|
||||||
obj.load(window, doc.dactylLoaded);
|
obj.load(window);
|
||||||
else
|
else
|
||||||
doc.addEventListener("load", wrapCallback(function load(event) {
|
doc.addEventListener("load", wrapCallback(function load(event) {
|
||||||
if (event.originalTarget === event.target) {
|
if (event.originalTarget === event.target) {
|
||||||
doc.removeEventListener("load", load.wrapper, true);
|
doc.removeEventListener("load", load.wrapper, true);
|
||||||
doc.dactylLoaded = event;
|
|
||||||
obj.load(window, event);
|
obj.load(window, event);
|
||||||
}
|
}
|
||||||
}), true);
|
}), true);
|
||||||
@@ -981,10 +980,8 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
},
|
},
|
||||||
"toplevel-window-ready": function (window, data) {
|
"toplevel-window-ready": function (window, data) {
|
||||||
window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) {
|
window.addEventListener("DOMContentLoaded", wrapCallback(function listener(event) {
|
||||||
window.dactylDOMLoaded = false;
|
|
||||||
if (event.originalTarget === window.document) {
|
if (event.originalTarget === window.document) {
|
||||||
window.removeEventListener("DOMContentLoaded", listener.wrapper, true);
|
window.removeEventListener("DOMContentLoaded", listener.wrapper, true);
|
||||||
window.document.dactylDOMLoaded = event;
|
|
||||||
util._loadOverlays(window);
|
util._loadOverlays(window);
|
||||||
}
|
}
|
||||||
}), true)
|
}), true)
|
||||||
@@ -1001,14 +998,12 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
this.overlays[url].push(fn);
|
this.overlays[url].push(fn);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
for (let win in iter(services.windowMediator.getEnumerator(null))) {
|
for (let win in iter(services.windowMediator.getEnumerator(null)))
|
||||||
util.dump("checkOverlay", win.document.dactylDOMLoaded, win.document.location.href);
|
if (["interactive", "complete"].indexOf(win.document.readyState) >= 0)
|
||||||
if (win.document.dactylDOMLoaded || win.dactylDOMLoaded !== false)
|
|
||||||
this._loadOverlays(win);
|
this._loadOverlays(win);
|
||||||
else
|
else
|
||||||
this.observe(win, "toplevel-window-ready");
|
this.observe(win, "toplevel-window-ready");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user