mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-13 09:25:44 +01:00
Merge changes from bootstrapped.
This commit is contained in:
@@ -147,6 +147,40 @@ const Buffer = Module("buffer", {
|
||||
let elem = event.originalTarget;
|
||||
buffer.viewSource([elem.getAttribute("href"), Number(elem.getAttribute("line"))])
|
||||
};
|
||||
|
||||
this.replaceProgressListener(this.progressListener);
|
||||
},
|
||||
|
||||
cleanup: function () {
|
||||
for (let prop in properties(this.progressListener))
|
||||
if (!this.progressListener.__lookupGetter__(prop) &&
|
||||
!callable(this.progressListener[prop]))
|
||||
this.origProgressListener[prop] = this.progressListener[prop]
|
||||
|
||||
this.replaceProgressListener(this.origProgressListener);
|
||||
},
|
||||
|
||||
replaceProgressListener: function (newListener) {
|
||||
// I hate this whole hack. --Kris
|
||||
let obj = window.XULBrowserWindow, getter;
|
||||
for (let prop in properties(obj))
|
||||
if ((getter = obj.__lookupGetter__(prop)) && !obj.__lookupSetter__(prop)) {
|
||||
newListener.__defineGetter__(prop, getter);
|
||||
delete obj[prop];
|
||||
}
|
||||
|
||||
this.origProgressListener = window.XULBrowserWindow;
|
||||
try {
|
||||
config.browser.removeProgressListener(window.XULBrowserWindow);
|
||||
}
|
||||
catch (e) {} // Why? --djk
|
||||
|
||||
config.browser.addProgressListener(newListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
||||
window.XULBrowserWindow = newListener;
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow)
|
||||
.XULBrowserWindow = newListener;
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
@@ -1502,26 +1536,6 @@ const Buffer = Module("buffer", {
|
||||
};
|
||||
},
|
||||
events: function () {
|
||||
try {
|
||||
config.browser.removeProgressListener(window.XULBrowserWindow);
|
||||
}
|
||||
catch (e) {} // Why? --djk
|
||||
|
||||
// I hate this whole hack. --Kris
|
||||
let obj = window.XULBrowserWindow, getter;
|
||||
for (let p in properties(obj))
|
||||
if ((getter = obj.__lookupGetter__(p)) && !obj.__lookupSetter__(p)) {
|
||||
this.progressListener.__defineGetter__(p, getter);
|
||||
delete obj[p];
|
||||
}
|
||||
|
||||
config.browser.addProgressListener(this.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
|
||||
window.XULBrowserWindow = this.progressListener;
|
||||
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
|
||||
.QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
|
||||
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow)
|
||||
.XULBrowserWindow = this.progressListener;
|
||||
|
||||
events.addSessionListener(config.browser, "DOMContentLoaded", this.closure.onDOMContentLoaded, true);
|
||||
events.addSessionListener(config.browser, "load", this.closure.onPageLoad, true);
|
||||
events.addSessionListener(config.browser, "scroll", this.closure._updateBufferPosition, false);
|
||||
|
||||
@@ -67,6 +67,7 @@ const CommandWidgets = Class("CommandWidgets", {
|
||||
getGroup: function (value) {
|
||||
if (this.command && !options.get("guioptions").has("M"))
|
||||
return this.statusbar;
|
||||
|
||||
let statusElem = this.statusbar.message;
|
||||
if (value && statusElem.editor.rootElement.scrollWidth > statusElem.scrollWidth)
|
||||
return this.commandbar;
|
||||
@@ -84,6 +85,14 @@ const CommandWidgets = Class("CommandWidgets", {
|
||||
return this.commandbar;
|
||||
}
|
||||
});
|
||||
|
||||
let fontSize = util.computedStyle(document.getElementById(config.mainWindowId)).fontSize;
|
||||
styles.registerSheet("chrome://dactyl/skin/dactyl.css");
|
||||
styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml",
|
||||
"body { font-size: " + fontSize + "; }");
|
||||
},
|
||||
cleanup: function cleanup() {
|
||||
styles.unregisterSheet("chrome://dactyl/skin/dactyl.css");
|
||||
},
|
||||
addElement: function (obj) {
|
||||
const self = this;
|
||||
@@ -1742,12 +1751,6 @@ const CommandLine = Module("commandline", {
|
||||
host && (!item.domains || !item.domains.some(function (d) util.isSubdomain(d, host))));
|
||||
}
|
||||
});
|
||||
},
|
||||
styles: function () {
|
||||
let fontSize = util.computedStyle(document.getElementById(config.mainWindowId)).fontSize;
|
||||
styles.registerSheet("chrome://dactyl/skin/dactyl.css");
|
||||
styles.system.add("font-size", "chrome://dactyl/content/buffer.xhtml",
|
||||
"body { font-size: " + fontSize + "; }");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -530,9 +530,9 @@ const CompletionContext = Class("CompletionContext", {
|
||||
// of the given string which also matches the current
|
||||
// item's text.
|
||||
let len = substring.length;
|
||||
let i = 0, m, n = len;
|
||||
let i = 0, n = len;
|
||||
while (n) {
|
||||
m = Math.floor(n / 2);
|
||||
let m = Math.floor(n / 2);
|
||||
let keep = compare(fixCase(item.text), substring.substring(0, i + m));
|
||||
if (!keep)
|
||||
len = i + m - 1;
|
||||
|
||||
@@ -37,6 +37,19 @@ const Dactyl = Module("dactyl", {
|
||||
};
|
||||
},
|
||||
|
||||
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", {});
|
||||
},
|
||||
|
||||
/** @property {string} The name of the current user profile. */
|
||||
profileName: Class.memoize(function () {
|
||||
// NOTE: services.profile.selectedProfile.name doesn't return
|
||||
@@ -52,14 +65,6 @@ const Dactyl = Module("dactyl", {
|
||||
return "unknown";
|
||||
}),
|
||||
|
||||
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.
|
||||
* @see modes#mainModes
|
||||
|
||||
@@ -13,20 +13,21 @@ plugins.contexts = {};
|
||||
function Script(file) {
|
||||
let self = set.has(plugins, file.path) && plugins[file.path];
|
||||
if (self) {
|
||||
if (self.onUnload)
|
||||
if (set.has(self, "onUnload"))
|
||||
self.onUnload();
|
||||
}
|
||||
else {
|
||||
self = { __proto__: plugins };
|
||||
plugins[file.path] = self;
|
||||
self.NAME = file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase());
|
||||
self.PATH = file.path;
|
||||
self.CONTEXT = self;
|
||||
self = update({ __proto__: plugins }, {
|
||||
NAME: file.leafName.replace(/\..*/, "").replace(/-([a-z])/g, function (m, n1) n1.toUpperCase()),
|
||||
PATH: file.path,
|
||||
CONTEXT: self
|
||||
});
|
||||
Class.replaceProperty(plugins, file.path, self);
|
||||
|
||||
// This belongs elsewhere
|
||||
if (io.getRuntimeDirectories("plugins").some(
|
||||
function (dir) dir.contains(file, false)))
|
||||
plugins[self.NAME] = self;
|
||||
Class.replaceProperty(plugins, self.NAME, self);
|
||||
}
|
||||
plugins.contexts[file.path] = self;
|
||||
return self;
|
||||
@@ -67,6 +68,13 @@ const IO = Module("io", {
|
||||
services.downloadManager.addListener(this.downloadListener);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
services.downloadManager.removeListener(this.downloadListener);
|
||||
for (let [, plugin] in Iterator(plugins.contexts))
|
||||
if (plugin.onUnload)
|
||||
plugin.onUnload();
|
||||
},
|
||||
|
||||
// TODO: there seems to be no way, short of a new component, to change
|
||||
// the process's CWD - see https://bugzilla.mozilla.org/show_bug.cgi?id=280953
|
||||
/**
|
||||
@@ -111,13 +119,6 @@ const IO = Module("io", {
|
||||
return this.cwd;
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
services.downloadManager.removeListener(this.downloadListener);
|
||||
for (let [, plugin] in Iterator(plugins.contexts))
|
||||
if (plugin.onUnload)
|
||||
plugin.onUnload();
|
||||
},
|
||||
|
||||
/**
|
||||
* @property {function} File class.
|
||||
* @final
|
||||
|
||||
@@ -36,6 +36,15 @@ const Tabs = Module("tabs", {
|
||||
};
|
||||
},
|
||||
|
||||
cleanup: function cleanup() {
|
||||
for (let [i, tab] in Iterator(this.allTabs)) {
|
||||
function node(clas) document.getAnonymousElementByAttribute(tab, "class", clas);
|
||||
for (let elem in values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
||||
if (elem)
|
||||
elem.parentNode.parentNode.removeChild(elem.parentNode);
|
||||
}
|
||||
},
|
||||
|
||||
_updateTabCount: function () {
|
||||
if (dactyl.has("Gecko2"))
|
||||
for (let [i, tab] in Iterator(this.visibleTabs)) {
|
||||
@@ -43,15 +52,15 @@ const Tabs = Module("tabs", {
|
||||
if (!node("dactyl-tab-number")) {
|
||||
let nodes = {};
|
||||
let dom = util.xmlToDom(<xul xmlns:xul={XUL} xmlns:html={XHTML}
|
||||
><xul:hbox highlight="tab-number"><xul:label key="icon" align="center" highlight="TabIconNumber" class="dactyl-tab-number"/></xul:hbox
|
||||
><xul:hbox highlight="tab-number"><html:div key="label" highlight="TabNumber"/></xul:hbox
|
||||
><xul:hbox highlight="tab-number"><xul:label key="icon" align="center" highlight="TabIconNumber" class="dactyl-tab-icon-number"/></xul:hbox
|
||||
><xul:hbox highlight="tab-number"><html:div key="label" highlight="TabNumber" class="dactyl-tab-number"/></xul:hbox
|
||||
></xul>.*, document, nodes);
|
||||
let img = node("tab-icon-image");
|
||||
img.parentNode.appendChild(dom);
|
||||
tab.__defineGetter__("ordinal", function () Number(nodes.icon.value));
|
||||
tab.__defineSetter__("ordinal", function (i) nodes.icon.value = nodes.label.textContent = i);
|
||||
tab.__defineGetter__("dactylOrdinal", function () Number(nodes.icon.value));
|
||||
tab.__defineSetter__("dactylOrdinal", function (i) nodes.icon.value = nodes.label.textContent = i);
|
||||
}
|
||||
tab.ordinal = i + 1;
|
||||
tab.dactylOrdinal = i + 1;
|
||||
}
|
||||
statusline.updateTabCount(true);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user