From 9f0cecb9f73cc4754a34133e095d1e4c85787538 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 7 Feb 2011 18:49:26 -0500 Subject: [PATCH 1/3] Import fixes from groups branch. --- common/content/commands.js | 2 +- common/content/events.js | 6 ++++-- common/content/modes.js | 2 +- common/modules/finder.jsm | 13 ++++--------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/common/content/commands.js b/common/content/commands.js index 131589e0..503e697b 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -1330,7 +1330,7 @@ var Commands = Module("commands", { args["-description"], Command.bindMacro(args, "-ex", function makeParams(args, modifiers) ({ - args: { + args: { __proto__: args, toString: function () this.string, }, diff --git a/common/content/events.js b/common/content/events.js index 26217d4a..ca8f5646 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -57,8 +57,10 @@ var ProcessorStack = Class("ProcessorStack", { events.feedingKeys = false; } - for (var res = this.actions[0]; callable(res);) - res = res(); + for (var res = this.actions[0]; callable(res);) { + res = dactyl.trapErrors(res); + dbg("ACTION RES: " + res); + } result = res === Events.PASS ? Events.PASS : Events.KILL; } else if (result !== Events.KILL && !this.actions.length && diff --git a/common/content/modes.js b/common/content/modes.js index 560f616d..a55d1b4e 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -424,7 +424,7 @@ var Modes = Module("modes", { hidden: false, - input: false, + input: Class.memoize(function () this.bases.length && this.bases.some(function (b) b.input)), get passUnknown() this.input, diff --git a/common/modules/finder.jsm b/common/modules/finder.jsm index 1e959f27..57afe86b 100644 --- a/common/modules/finder.jsm +++ b/common/modules/finder.jsm @@ -165,22 +165,16 @@ var RangeFinder = Module("rangefinder", { modes: function (dactyl, modules, window) { const { modes } = modules; modes.addMode("FIND", { - extended: true, description: "Find mode, active when typing search input", bases: [modes.COMMAND_LINE], - input: true }); modes.addMode("FIND_FORWARD", { - extended: true, description: "Forward Find mode, active when typing search input", - bases: [modes.FIND], - input: true + bases: [modes.FIND] }); modes.addMode("FIND_BACKWARD", { - extended: true, description: "Backward Find mode, active when typing search input", - bases: [modes.FIND], - input: true + bases: [modes.FIND] }); }, commands: function (dactyl, modules, window) { @@ -191,7 +185,8 @@ var RangeFinder = Module("rangefinder", { { argCount: "0" }); }, commandline: function (dactyl, modules, window) { - this.CommandMode = Class("CommandFindMode", modules.CommandMode, { + const { rangefinder } = modules; + rangefinder.CommandMode = Class("CommandFindMode", modules.CommandMode, { init: function init(mode) { this.mode = mode; init.supercall(this); From 0290f6ebcd5797bd8e7b8304582f703d52b35a85 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 7 Feb 2011 23:12:09 -0500 Subject: [PATCH 2/3] Minor cleanup. --- common/content/commandline.js | 12 ++++++------ common/content/dactyl.js | 3 +-- common/content/events.js | 6 ++---- common/content/tabs.js | 8 +++++--- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/common/content/commandline.js b/common/content/commandline.js index a61bfa57..af0a70a3 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -260,9 +260,10 @@ var CommandWidgets = Class("CommandWidgets", { configurable: true, enumerable: true, get: function get_whenReady() { let elem = document.getElementById(id); - while (elem.contentDocument.documentURI != elem.getAttribute("src") || - ["viewable", "complete"].indexOf(elem.contentDocument.readyState) < 0) - util.threadYield(); + + util.waitFor(function () elem.contentDocument.documentURI === elem.getAttribute("src") && + ["viewable", "complete"].indexOf(elem.contentDocument.readyState) >= 0); + res = res || (processor || util.identity).call(self, elem); return res; } @@ -1189,9 +1190,8 @@ var CommandLine = Module("commandline", { this.waiting = true; for (let [, context] in Iterator(list)) { let done = function done() !(idx >= n + context.items.length || idx == -2 && !context.items.length); - while (context.incomplete && !done()) - util.threadYield(false, true); + util.waitFor(function () !context.incomplete || done()) if (done()) break; @@ -1420,7 +1420,7 @@ var CommandLine = Module("commandline", { let command = commandline.command; self.accepted = true; - return function () modes.pop(); + return function () { modes.pop(); }; }); [ diff --git a/common/content/dactyl.js b/common/content/dactyl.js index b5003ca3..221393b2 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1191,8 +1191,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { case dactyl.NEW_WINDOW: let win = window.openDialog(document.documentURI, "_blank", "chrome,all,dialog=no"); - while (win.document.readyState != "complete") - util.threadYield(); + util.waitFor(function () win.document.readyState === "complete"); browser = win.getBrowser(); // FALLTHROUGH case dactyl.CURRENT_TAB: diff --git a/common/content/events.js b/common/content/events.js index ca8f5646..fdb69943 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -526,7 +526,7 @@ var Events = Module("events", { if (quiet) commandline.quiet = quiet; - util.threadYield(1, true); + util.threadYield(1, true); // Why? --Kris for (let [, evt_obj] in Iterator(events.fromString(keys))) { let now = Date.now(); @@ -922,8 +922,6 @@ var Events = Module("events", { * @returns {boolean} */ waitForPageLoad: function (time) { - util.threadYield(true); // clear queue - if (buffer.loaded) return true; @@ -1267,7 +1265,7 @@ var Events = Module("events", { let urlbar = document.getElementById("urlbar"); if (elem == null && urlbar && urlbar.inputField == this._lastFocus) - util.threadYield(true); + util.threadYield(true); // Why? --Kris while (modes.main.ownsFocus) modes.pop(null, { fromFocus: true }); diff --git a/common/content/tabs.js b/common/content/tabs.js index 5b129953..e7754fe1 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -203,12 +203,14 @@ var Tabs = Module("tabs", { getGroups: function () { if ("_groups" in this) return this._groups; + if (window.TabView && TabView._initFrame) TabView._initFrame(); + let iframe = document.getElementById("tab-view"); - this._groups = this._groups = iframe ? iframe.contentWindow : null; - while (this._groups && !this._groups.TabItems) - util.threadYield(false, true); + this._groups = iframe ? iframe.contentWindow : null; + if (this._groups) + util.waitFor(function () this._groups.TabItems, this); return this._groups; }, From 263df6bf5aecb8f53d26a5fcbd640252f5e7419e Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 7 Feb 2011 23:15:31 -0500 Subject: [PATCH 3/3] Experimentally remove the threadYield call in events.feedkeys. --- common/content/events.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index fdb69943..c4db8f8c 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -526,8 +526,6 @@ var Events = Module("events", { if (quiet) commandline.quiet = quiet; - util.threadYield(1, true); // Why? --Kris - for (let [, evt_obj] in Iterator(events.fromString(keys))) { let now = Date.now(); for (let type in values(["keydown", "keyup", "keypress"])) {