diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-02-07 23:12:09 -0500 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-02-07 23:12:09 -0500 |
commit | 0290f6ebcd5797bd8e7b8304582f703d52b35a85 (patch) | |
tree | 31bb6956f25e98fce0e9a442a50d3e3eb379ccd4 | |
parent | 9f0cecb9f73cc4754a34133e095d1e4c85787538 (diff) | |
download | pentadactyl-0290f6ebcd5797bd8e7b8304582f703d52b35a85.tar.gz |
Minor cleanup.
-rw-r--r-- | common/content/commandline.js | 12 | ||||
-rw-r--r-- | common/content/dactyl.js | 3 | ||||
-rw-r--r-- | common/content/events.js | 6 | ||||
-rw-r--r-- | 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; }, |