diff --git a/common/content/buffer.js b/common/content/buffer.js index 0e7e242c..4cc84adb 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -185,7 +185,7 @@ const Buffer = Module("buffer", { // hacky way to get rid of "Transfering data from ..." on sites with frames // when you click on a link inside a frameset, because asyncUpdateUI // is not triggered there (Gecko bug?) - setTimeout(function () { statusline.updateUrl(); }, 10); + this.timeout(function () { statusline.updateUrl(); }, 10); return; } @@ -224,7 +224,7 @@ const Buffer = Module("buffer", { // don't reset mode if a frame of the frameset gets reloaded which // is not the focused frame if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow) { - setTimeout(function () { modes.reset(false); }, + util.timeout(function () { modes.reset(false); }, dactyl.mode == modes.HINTS ? 500 : 0); } } @@ -264,7 +264,7 @@ const Buffer = Module("buffer", { autocommands.trigger("LocationChange", { url: buffer.URL }); // if this is not delayed we get the position of the old buffer - setTimeout(function () { + util.timeout(function () { statusline.updateBufferPosition(); statusline.updateZoomLevel(); modes.show(); // Clear the status line. @@ -273,7 +273,7 @@ const Buffer = Module("buffer", { // called at the very end of a page load asyncUpdateUI: function asyncUpdateUI() { asyncUpdateUI.superapply(this, arguments); - setTimeout(function () { statusline.updateUrl(); }, 100); + util.timeout(function () { statusline.updateUrl(); }, 100); }, setOverLink: function setOverLink(link, b) { setOverLink.superapply(this, arguments); @@ -843,11 +843,11 @@ const Buffer = Module("buffer", { let indicator = util.xmlToDom(
, doc); doc.body.appendChild(indicator); - setTimeout(function () { doc.body.removeChild(indicator); }, 500); + util.timeout(function () { doc.body.removeChild(indicator); }, 500); // Doesn't unattach //doc.body.setAttributeNS(NS.uri, "activeframe", "true"); - //setTimeout(function () { doc.body.removeAttributeNS(NS.uri, "activeframe"); }, 500); + //util.timeout(function () { doc.body.removeAttributeNS(NS.uri, "activeframe"); }, 500); }, // similar to pageInfo diff --git a/common/content/commandline.js b/common/content/commandline.js index 38f22733..6d5b920d 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -590,7 +590,7 @@ const CommandLine = Module("commandline", { this.widgets.multilineInput.value = ""; this._autosizeMultilineInputWidget(); - this.setTimeout(function () { this.widgets.multilineInput.focus(); }, 10); + this.timeout(function () { this.widgets.multilineInput.focus(); }, 10); }, /** @@ -607,7 +607,7 @@ const CommandLine = Module("commandline", { if (event.type == "blur") { // prevent losing focus, there should be a better way, but it just didn't work otherwise - this.setTimeout(function () { + this.timeout(function () { if (this.commandVisible && event.originalTarget == this.widgets.command.inputField) this.widgets.command.inputField.focus(); }, 0); @@ -707,7 +707,7 @@ const CommandLine = Module("commandline", { } else if (event.type == "blur") { if (modes.extended & modes.INPUT_MULTILINE) - this.setTimeout(function () { this.widgets.multilineInput.inputField.focus(); }, 0); + this.timeout(function () { this.widgets.multilineInput.inputField.focus(); }, 0); } else if (event.type == "input") this._autosizeMultilineInputWidget(); @@ -1586,7 +1586,7 @@ const ItemList = Class("ItemList", { // FIXME: Belongs elsewhere. commandline.updateOutputHeight(false); - this.setTimeout(function () { this._container.height -= commandline.getSpaceNeeded(); }, 0); + this.timeout(function () { this._container.height -= commandline.getSpaceNeeded(); }, 0); }, _getCompletion: function (index) this._completionElements.snapshotItem(index - this._startIndex), @@ -1627,7 +1627,7 @@ const ItemList = Class("ItemList", { this._divNodes.completions.appendChild(context.cache.nodes.root); }, this); - setTimeout(this.closure._autoSize, 0); + this.timeout(this._autoSize, 0); }, /** diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e491b9c2..509c3725 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -129,7 +129,7 @@ const Dactyl = Module("dactyl", { // NOTE: this doesn't seem to work in FF3 with full box dimensions popup.openPopup(win, "overlap", 1, 1, false, false); popup.sizeTo(width - 2, height - 2); - setTimeout(function () { popup.hidePopup(); }, 20); + util.timeout(function () { popup.hidePopup(); }, 20); } else { let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound); @@ -1888,7 +1888,7 @@ const Dactyl = Module("dactyl", { // first time intro message const firstTime = "extensions." + config.name.toLowerCase() + ".firsttime"; if (options.getPref(firstTime, true)) { - setTimeout(function () { + util.timeout(function () { dactyl.help(); options.setPref(firstTime, false); }, 1000); @@ -1907,7 +1907,7 @@ const Dactyl = Module("dactyl", { // finally, read the RC file and source plugins // make sourcing asynchronous, otherwise commands that open new tabs won't work - setTimeout(function () { + util.timeout(function () { let extensionName = config.name.toUpperCase(); let init = services.get("environment").get(extensionName + "_INIT"); let rcFile = io.getRCFile("~"); diff --git a/common/content/editor.js b/common/content/editor.js index 9a517073..25b4f461 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -409,7 +409,7 @@ const Editor = Module("editor", { (function next() { textBox.style.backgroundColor = colors.shift(); if (colors.length > 0) - setTimeout(next, 100); + util.timeout(next, 100); })(); } diff --git a/common/content/events.js b/common/content/events.js index 03e5296f..ddfd4697 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -74,8 +74,8 @@ const Events = Module("events", { }; // load all macros - // setTimeout needed since io. is loaded after events. - setTimeout(function () { + // util.timeout needed since io. is loaded after events. + this.timeout(function () { try { let dirs = io.getRuntimeDirectories("macros"); @@ -849,7 +849,7 @@ const Events = Module("events", { events.feedingKeys = false; if (modes.isReplaying) { modes.isReplaying = false; - this.setTimeout(function () { dactyl.echomsg("Canceled playback of macro '" + this._lastMacro + "'"); }, 100); + this.timeout(function () { dactyl.echomsg("Canceled playback of macro '" + this._lastMacro + "'"); }, 100); } } else diff --git a/common/content/finder.js b/common/content/finder.js index 21650c83..95c2356d 100644 --- a/common/content/finder.js +++ b/common/content/finder.js @@ -64,7 +64,7 @@ const RangeFinder = Module("rangefinder", { find: function (pattern, backwards) { let str = this.bootstrap(pattern); if (!this.rangeFind.search(str)) - setTimeout(function () { dactyl.echoerr("E486: Pattern not found: " + pattern); }, 0); + this.timeout(function () { dactyl.echoerr("E486: Pattern not found: " + pattern); }, 0); return this.rangeFind.found; }, @@ -77,7 +77,7 @@ const RangeFinder = Module("rangefinder", { else if (this.rangeFind.wrapped) // hack needed, because wrapping causes a "scroll" event which // clears our command line - this.setTimeout(function () { + this.timeout(function () { let msg = this.rangeFind.backward ? "search hit TOP, continuing at BOTTOM" : "search hit BOTTOM, continuing at TOP"; commandline.echo(msg, commandline.HL_WARNINGMSG, diff --git a/common/content/hints.js b/common/content/hints.js index 1ddf33b5..5bb503a7 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -412,7 +412,7 @@ const Hints = Module("hints", { // animate the disappearance of the first hint if (timeout && firstElem) - setTimeout(function () { firstElem.removeAttributeNS(NS.uri, "highlight"); }, timeout); + this.timeout(function () { firstElem.removeAttributeNS(NS.uri, "highlight"); }, timeout); } styles.removeSheet(true, "hint-positions"); @@ -465,7 +465,7 @@ const Hints = Module("hints", { // force a possible mode change, based on whether an input field has focus events.onFocusChange(); - this.setTimeout(function () { + this.timeout(function () { if (modes.extended & modes.HINTS) modes.reset(); this._hintMode.action(elem, elem.href || "", this._extendedhintCount); @@ -483,7 +483,7 @@ const Hints = Module("hints", { if (this._hintNumber > 0 && this._hintNumber * 10 <= this._validHints.length) { let timeout = options["hinttimeout"]; if (timeout > 0) - this._activeTimeout = this.setTimeout(function () { this._processHints(true); }, timeout); + this._activeTimeout = this.timeout(function () { this._processHints(true); }, timeout); } else // we have a unique hint this._processHints(true); @@ -998,7 +998,7 @@ const Hints = Module("hints", { context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints._hintModes))]; }, onChange: function () { modes.pop(); }, - onCancel: function (arg) { arg && setTimeout(function () hints.show(arg), 0); } + onCancel: function (arg) { arg && util.timeout(function () hints.show(arg), 0); } }); }, { count: true }); }, diff --git a/common/content/statusline.js b/common/content/statusline.js index b40374ce..f88aa79a 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -182,7 +182,7 @@ const StatusLine = Module("statusline", { updateTabCount: function updateTabCount(delayed) { if (dactyl.has("tabs")) { if (delayed) { - this.setTimeout(function () this.updateTabCount(false), 0); + this.timeout(function () this.updateTabCount(false), 0); return; } diff --git a/common/content/tabs.js b/common/content/tabs.js index f258f835..5312054e 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -38,7 +38,7 @@ const Tabs = Module("tabs", { statusline.updateTabCount(true); this.updateSelectionHistory(); if (options["focuscontent"]) - setTimeout(function () { dactyl.focusContent(true); }, 10); // just make sure, that no widget has focus + this.timeout(function () { dactyl.focusContent(true); }, 10); // just make sure, that no widget has focus }, get allTabs() Array.slice(config.tabbrowser.tabContainer.childNodes), diff --git a/common/modules/base.jsm b/common/modules/base.jsm index d3abaa96..774347cb 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -528,16 +528,15 @@ Class.prototype = { toString: function () "[instance " + this.constructor.name + "]", /** - * Exactly like {@see nsIDOMWindow#setTimeout}, except that it - * preserves the value of 'this' on invocation of 'callback'. + * Executes 'callback' after 'timeout' milliseconds. The value of + * 'this' is preserved in the invocation of 'callback'. * * @param {function} callback The function to call after 'timeout' - * @param {number} timeout The timeout, in seconds, to wait + * @param {number} timeout The time, in milliseconds, to wait * before calling 'callback'. - * @returns {integer} The ID of this timeout, to be passed to - * {@see nsIDOMWindow#clearTimeout}. + * @returns {nsITimer} The timer which backs this timeout. */ - setTimeout: function (callback, timeout) { + timeout: function (callback, timeout) { const self = this; let notify = { notify: function notify(timer) { callback.call(self) } }; let timer = services.create("timer"); diff --git a/muttator/content/mail.js b/muttator/content/mail.js index c45dfce6..80699221 100644 --- a/muttator/content/mail.js +++ b/muttator/content/mail.js @@ -80,7 +80,7 @@ const Mail = Module("mail", { return void dactyl.beep(); (copy ? MsgCopyMessage : MsgMoveMessage)(folders[0]); - setTimeout(function () { + util.timeout(function () { dactyl.echomsg(count + " message(s) " + (copy ? "copied" : "moved") + " to " + folders[0].prettyName, 1); }, 100); }, diff --git a/xulmus/content/player.js b/xulmus/content/player.js index 79f02969..1d223fde 100644 --- a/xulmus/content/player.js +++ b/xulmus/content/player.js @@ -270,7 +270,7 @@ const Player = Module("player", { */ searchViewAgain: function searchViewAgain(reverse) { function echo(str) { - setTimeout(function () { + this.timeout(function () { commandline.echo(str, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE); }, 0); }