1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-16 15:45:46 +01:00

Fix some startup bottlenecks.

This commit is contained in:
Kris Maglione
2015-12-21 00:52:38 -08:00
parent 5a42ae42d6
commit 7aabc153f5
8 changed files with 136 additions and 69 deletions

View File

@@ -317,8 +317,11 @@ var CommandWidgets = Class("CommandWidgets", {
return document.getElementById("dactyl-contextmenu");
}),
multilineOutputReady: false,
multilineOutput: Class.Memoize(function () {
return this._whenReady("dactyl-multiline-output", elem => {
this.multilineOutputReady = true;
highlight.highlightNode(elem.contentDocument.body, "MOW");
});
}, true),

View File

@@ -18,15 +18,14 @@ var ProcessorStack = Class("ProcessorStack", {
events.dbg("STACK " + mode);
let main = { __proto__: mode.main, params: mode.params };
this.modes = Ary([mode.params.keyModes,
main,
mode.main.allBases.slice(1)]).flatten().compact();
this.modes = [...(mode.params.keyModes || []),
main,
...mode.main.allBases.slice(1)];
if (builtin)
hives = hives.filter(h => h.name === "builtin");
this.processors = this.modes.map(m => hives.map(h => KeyProcessor(m, h)))
.flatten().array;
this.processors = this.modes.flatMap(mode => hives.map(hive => KeyProcessor(mode, hive)))
this.ownsBuffer = !this.processors.some(p => p.main.ownsBuffer);
for (let input of this.processors) {
@@ -83,7 +82,7 @@ var ProcessorStack = Class("ProcessorStack", {
if (this.ownsBuffer)
statusline.inputBuffer = this.processors.length ? this.buffer : "";
if (!this.processors.some(p => !p.extended) && this.actions.length) {
if (this.processors.every(p => p.extended) && this.actions.length) {
// We have matching actions and no processors other than
// those waiting on further arguments. Execute actions as
// long as they continue to return PASS.
@@ -115,9 +114,8 @@ var ProcessorStack = Class("ProcessorStack", {
}
else if (result !== Events.KILL && !this.actions.length &&
!(this.events[0].isReplay || this.passUnknown ||
this.modes.some(function (m) {
return m.passEvent(this);
}, this.events[0]))) {
this.modes.some(mode => mode.passEvent(this.events[0])))) {
// No patching processors, this isn't a fake, pass-through
// event, we're not in pass-through mode, and we're not
// choosing to pass unknown keys. Kill the event and beep.

View File

@@ -306,6 +306,11 @@ var MOW = Module("mow", {
set: function set_mowVisible(value) {
this.widgets.mowContainer.collapsed = !value;
// Don't block on the MOW iframe loading if we don't
// actually need it.
if (!value && !commandline.multilineOutputReady)
return;
let elem = this.widget;
if (!value && elem && elem.contentWindow == document.commandDispatcher.focusedWindow) {