mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-21 00:37:58 +01:00
[bootstrap] Changes toward proper reinitialization after disabling.
--HG-- branch : bootstrapped
This commit is contained in:
19
common/bootstrap.js
vendored
19
common/bootstrap.js
vendored
@@ -10,12 +10,13 @@ const Cr = Components.results;
|
|||||||
|
|
||||||
Cu.import("resource://gre/modules/AddonManager.jsm");
|
Cu.import("resource://gre/modules/AddonManager.jsm");
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
|
||||||
const io = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
const resourceProto = Services.io.getProtocolHandler("resource")
|
||||||
const resourceProto = io.getProtocolHandler("resource")
|
|
||||||
.QueryInterface(Ci.nsIResProtocolHandler);
|
.QueryInterface(Ci.nsIResProtocolHandler);
|
||||||
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
const categoryManager = Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
|
||||||
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
const manager = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||||
|
const storage = Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication);
|
||||||
|
|
||||||
function httpGet(url) {
|
function httpGet(url) {
|
||||||
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
let xmlhttp = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||||
@@ -70,23 +71,27 @@ function FactoryProxy(url, classID) {
|
|||||||
FactoryProxy.prototype = {
|
FactoryProxy.prototype = {
|
||||||
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
|
QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory),
|
||||||
register: function () {
|
register: function () {
|
||||||
|
dump("dactyl: bootstrap: register: " + this.classID + " " + this.contractID + "\n");
|
||||||
manager.registerFactory(this.classID,
|
manager.registerFactory(this.classID,
|
||||||
String(this.classID),
|
String(this.classID),
|
||||||
this.contractID,
|
this.contractID,
|
||||||
this);
|
this);
|
||||||
},
|
},
|
||||||
unregister: function () {
|
unregister: function () {
|
||||||
|
dump("dactyl: bootstrap: unregister: " + this.classID + " " + this.contractID + "\n");
|
||||||
manager.unregisterFactory(this.classID,
|
manager.unregisterFactory(this.classID,
|
||||||
this);
|
this);
|
||||||
},
|
},
|
||||||
get module() {
|
get module() {
|
||||||
Class.replaceProperty(this, "module", {});
|
Object.defineProperty(this, "module", { value: {}, enumerable: true });
|
||||||
Cu.import(this.url, this.module);
|
Cu.import(this.url, this.module);
|
||||||
return this.module;
|
return this.module;
|
||||||
},
|
},
|
||||||
createInstance: function ()
|
createInstance: function (iids) {
|
||||||
let (factory = this.module.NSGetFactory(this.classID))
|
dump("dactyl: bootstrap: createInstance: " + this.classID + " " + this.contractID + " " + iids + "\n");
|
||||||
|
return let (factory = this.module.NSGetFactory(this.classID))
|
||||||
factory.createInstance.apply(factory, arguments)
|
factory.createInstance.apply(factory, arguments)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
@@ -133,6 +138,10 @@ function init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Cc["@dactyl.googlecode.com/base/xpc-interface-shim"].createInstance()
|
||||||
|
|
||||||
|
Services.obs.notifyObservers(null, "dactyl-rehash", null);
|
||||||
|
|
||||||
Cu.import("resource://dactyl/base.jsm");
|
Cu.import("resource://dactyl/base.jsm");
|
||||||
require(global, "prefs");
|
require(global, "prefs");
|
||||||
require(global, "services");
|
require(global, "services");
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
if (this.command && !options.get("guioptions").has("M"))
|
if (this.command && !options.get("guioptions").has("M"))
|
||||||
return this.statusbar;
|
return this.statusbar;
|
||||||
let statusElem = this.statusbar.message;
|
let statusElem = this.statusbar.message;
|
||||||
if (value && statusElem.editor.rootElement.scrollWidth > statusElem.scrollWidth)
|
if (value && statusElem.inputField.editor.rootElement.scrollWidth > statusElem.scrollWidth)
|
||||||
return this.commandbar;
|
return this.commandbar;
|
||||||
return this.activeGroup.mode;
|
return this.activeGroup.mode;
|
||||||
}
|
}
|
||||||
@@ -164,9 +164,12 @@ const CommandWidgets = Class("CommandWidgets", {
|
|||||||
addElement: function (obj) {
|
addElement: function (obj) {
|
||||||
const self = this;
|
const self = this;
|
||||||
this.elements[obj.name] = obj;
|
this.elements[obj.name] = obj;
|
||||||
|
|
||||||
function get(id) obj.getElement ? obj.getElement(id) : document.getElementById(id);
|
function get(id) obj.getElement ? obj.getElement(id) : document.getElementById(id);
|
||||||
|
|
||||||
this.active.__defineGetter__(obj.name, function () self.activeGroup[obj.name][obj.name]);
|
this.active.__defineGetter__(obj.name, function () self.activeGroup[obj.name][obj.name]);
|
||||||
this.activeGroup.__defineGetter__(obj.name, function () self.getGroup(obj.name));
|
this.activeGroup.__defineGetter__(obj.name, function () self.getGroup(obj.name));
|
||||||
|
|
||||||
memoize(this.statusbar, obj.name, function () get("dactyl-statusline-field-" + (obj.id || obj.name)));
|
memoize(this.statusbar, obj.name, function () get("dactyl-statusline-field-" + (obj.id || obj.name)));
|
||||||
memoize(this.commandbar, obj.name, function () get("dactyl-" + (obj.id || obj.name)));
|
memoize(this.commandbar, obj.name, function () get("dactyl-" + (obj.id || obj.name)));
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,19 @@ const Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
cleanup: function () {
|
||||||
|
delete window.dactyl;
|
||||||
|
delete window.liberator;
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function () {
|
||||||
|
autocommands.trigger("LeavePre", {});
|
||||||
|
storage.saveAll();
|
||||||
|
dactyl.triggerObserver("shutdown", null);
|
||||||
|
util.dump("All dactyl modules destroyed\n");
|
||||||
|
autocommands.trigger("Leave", {});
|
||||||
|
},
|
||||||
|
|
||||||
observe: {
|
observe: {
|
||||||
"dactyl-cleanup": function () {
|
"dactyl-cleanup": function () {
|
||||||
for (let [, mod] in iter(array(values(modules)).reverse()))
|
for (let [, mod] in iter(array(values(modules)).reverse()))
|
||||||
@@ -65,20 +78,6 @@ const Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}),
|
}),
|
||||||
|
|
||||||
cleanup: function () {
|
|
||||||
delete window.dactyl;
|
|
||||||
delete window.modules;
|
|
||||||
delete window.liberator;
|
|
||||||
},
|
|
||||||
|
|
||||||
destroy: function () {
|
|
||||||
autocommands.trigger("LeavePre", {});
|
|
||||||
storage.saveAll();
|
|
||||||
dactyl.triggerObserver("shutdown", null);
|
|
||||||
util.dump("All dactyl modules destroyed\n");
|
|
||||||
autocommands.trigger("Leave", {});
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property {number} The current main mode.
|
* @property {number} The current main mode.
|
||||||
* @see modes#mainModes
|
* @see modes#mainModes
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ const ModuleBase = Class("ModuleBase", {
|
|||||||
toString: function () "[module " + this.constructor.className + "]"
|
toString: function () "[module " + this.constructor.className + "]"
|
||||||
});
|
});
|
||||||
|
|
||||||
util.overlayWindow("chrome://browser/content/browser.xul", function (window) ({
|
const Overlay = Module("Overlay", {
|
||||||
|
init: function () {
|
||||||
|
util.overlayWindow("chrome://browser/content/browser.xul", function (window) ({
|
||||||
init: function (document) {
|
init: function (document) {
|
||||||
/**
|
/**
|
||||||
* @constructor Module
|
* @constructor Module
|
||||||
@@ -253,7 +255,8 @@ util.overlayWindow("chrome://browser/content/browser.xul", function (window) ({
|
|||||||
mod.destroy();
|
mod.destroy();
|
||||||
}, false);
|
}, false);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// vim: set fdm=marker sw=4 ts=4 et:
|
// vim: set fdm=marker sw=4 ts=4 et:
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ const Services = Module("Services", {
|
|||||||
if (!this.extensionManager)
|
if (!this.extensionManager)
|
||||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||||
},
|
},
|
||||||
|
reinit: function () {},
|
||||||
|
|
||||||
_create: function (classes, ifaces, meth, init, args) {
|
_create: function (classes, ifaces, meth, init, args) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -55,10 +55,13 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
},
|
},
|
||||||
|
|
||||||
cleanup: function cleanup() {
|
cleanup: function cleanup() {
|
||||||
for (let win in iter(services.windowMediator.getEnumerator(null)))
|
for (let win in iter(services.windowMediator.getEnumerator(null))) {
|
||||||
for (let elem in values(win.document.dactylOverlayElements))
|
for (let elem in values(win.document.dactylOverlayElements || []))
|
||||||
if (elem.get() && elem.get().parentNode)
|
if (elem.get() && elem.get().parentNode)
|
||||||
elem.get().parentNode.removeChild(elem.get());
|
elem.get().parentNode.removeChild(elem.get());
|
||||||
|
delete win.document.dactylOverlayElements;
|
||||||
|
delete win.document.dactylOverlays;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Only works for Pentadactyl
|
// FIXME: Only works for Pentadactyl
|
||||||
@@ -962,6 +965,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
|
|
||||||
observe: {
|
observe: {
|
||||||
"dactyl-cleanup": function () {
|
"dactyl-cleanup": function () {
|
||||||
|
util.dump("dactyl: util: observe: dactyl-cleanup");
|
||||||
// Let window cleanup functions run synchronously before we
|
// Let window cleanup functions run synchronously before we
|
||||||
// destroy modules.
|
// destroy modules.
|
||||||
util.timeout(function () {
|
util.timeout(function () {
|
||||||
@@ -969,6 +973,9 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
if (module.cleanup)
|
if (module.cleanup)
|
||||||
module.cleanup();
|
module.cleanup();
|
||||||
|
|
||||||
|
services.observer.addObserver(this, "dactyl-rehash", true);
|
||||||
|
|
||||||
|
/*
|
||||||
let getOwnPropertyNames = Object.getOwnPropertyNames;
|
let getOwnPropertyNames = Object.getOwnPropertyNames;
|
||||||
for each (let global in defineModule.globals.reverse())
|
for each (let global in defineModule.globals.reverse())
|
||||||
for each (let k in getOwnPropertyNames(global))
|
for each (let k in getOwnPropertyNames(global))
|
||||||
@@ -976,8 +983,17 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
|
|||||||
delete global[k];
|
delete global[k];
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
"dactyl-rehash": function () {
|
||||||
|
util.dump("dactyl: util: observe: dactyl-rehash");
|
||||||
|
for (let module in values(defineModule.modules))
|
||||||
|
if (module.reinit)
|
||||||
|
module.reinit();
|
||||||
|
else
|
||||||
|
module.init();
|
||||||
|
},
|
||||||
"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) {
|
||||||
if (event.originalTarget === window.document) {
|
if (event.originalTarget === window.document) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@namespace dactyl url("http://vimperator.org/namespaces/liberator");
|
@namespace dactyl url("http://vimperator.org/namespaces/liberator");
|
||||||
@namespace html url("http://www.w3.org/1999/xhtml");
|
@namespace html url("http://www.w3.org/1999/xhtml");
|
||||||
@namespace xul uri("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||||
|
|
||||||
/* Applied to all content */
|
/* Applied to all content */
|
||||||
[dactyl|activeframe] {
|
[dactyl|activeframe] {
|
||||||
|
|||||||
Reference in New Issue
Block a user