1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 11:58:00 +01:00

Rename Class#setTimeout to appease AMO's validation grep.

This commit is contained in:
Kris Maglione
2010-09-17 06:15:13 -04:00
parent 8c0a734e53
commit b8331a1b55
12 changed files with 33 additions and 34 deletions

View File

@@ -185,7 +185,7 @@ const Buffer = Module("buffer", {
// hacky way to get rid of "Transfering data from ..." on sites with frames // hacky way to get rid of "Transfering data from ..." on sites with frames
// when you click on a link inside a frameset, because asyncUpdateUI // when you click on a link inside a frameset, because asyncUpdateUI
// is not triggered there (Gecko bug?) // is not triggered there (Gecko bug?)
setTimeout(function () { statusline.updateUrl(); }, 10); this.timeout(function () { statusline.updateUrl(); }, 10);
return; return;
} }
@@ -224,7 +224,7 @@ const Buffer = Module("buffer", {
// don't reset mode if a frame of the frameset gets reloaded which // don't reset mode if a frame of the frameset gets reloaded which
// is not the focused frame // is not the focused frame
if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow) { if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow) {
setTimeout(function () { modes.reset(false); }, util.timeout(function () { modes.reset(false); },
dactyl.mode == modes.HINTS ? 500 : 0); dactyl.mode == modes.HINTS ? 500 : 0);
} }
} }
@@ -264,7 +264,7 @@ const Buffer = Module("buffer", {
autocommands.trigger("LocationChange", { url: buffer.URL }); autocommands.trigger("LocationChange", { url: buffer.URL });
// if this is not delayed we get the position of the old buffer // if this is not delayed we get the position of the old buffer
setTimeout(function () { util.timeout(function () {
statusline.updateBufferPosition(); statusline.updateBufferPosition();
statusline.updateZoomLevel(); statusline.updateZoomLevel();
modes.show(); // Clear the status line. modes.show(); // Clear the status line.
@@ -273,7 +273,7 @@ const Buffer = Module("buffer", {
// called at the very end of a page load // called at the very end of a page load
asyncUpdateUI: function asyncUpdateUI() { asyncUpdateUI: function asyncUpdateUI() {
asyncUpdateUI.superapply(this, arguments); asyncUpdateUI.superapply(this, arguments);
setTimeout(function () { statusline.updateUrl(); }, 100); util.timeout(function () { statusline.updateUrl(); }, 100);
}, },
setOverLink: function setOverLink(link, b) { setOverLink: function setOverLink(link, b) {
setOverLink.superapply(this, arguments); setOverLink.superapply(this, arguments);
@@ -843,11 +843,11 @@ const Buffer = Module("buffer", {
let indicator = util.xmlToDom(<div highlight="FrameIndicator"/>, doc); let indicator = util.xmlToDom(<div highlight="FrameIndicator"/>, doc);
doc.body.appendChild(indicator); doc.body.appendChild(indicator);
setTimeout(function () { doc.body.removeChild(indicator); }, 500); util.timeout(function () { doc.body.removeChild(indicator); }, 500);
// Doesn't unattach // Doesn't unattach
//doc.body.setAttributeNS(NS.uri, "activeframe", "true"); //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 // similar to pageInfo

View File

@@ -590,7 +590,7 @@ const CommandLine = Module("commandline", {
this.widgets.multilineInput.value = ""; this.widgets.multilineInput.value = "";
this._autosizeMultilineInputWidget(); 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") { if (event.type == "blur") {
// prevent losing focus, there should be a better way, but it just didn't work otherwise // 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) if (this.commandVisible && event.originalTarget == this.widgets.command.inputField)
this.widgets.command.inputField.focus(); this.widgets.command.inputField.focus();
}, 0); }, 0);
@@ -707,7 +707,7 @@ const CommandLine = Module("commandline", {
} }
else if (event.type == "blur") { else if (event.type == "blur") {
if (modes.extended & modes.INPUT_MULTILINE) 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") else if (event.type == "input")
this._autosizeMultilineInputWidget(); this._autosizeMultilineInputWidget();
@@ -1586,7 +1586,7 @@ const ItemList = Class("ItemList", {
// FIXME: Belongs elsewhere. // FIXME: Belongs elsewhere.
commandline.updateOutputHeight(false); 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), _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._divNodes.completions.appendChild(context.cache.nodes.root);
}, this); }, this);
setTimeout(this.closure._autoSize, 0); this.timeout(this._autoSize, 0);
}, },
/** /**

View File

@@ -129,7 +129,7 @@ const Dactyl = Module("dactyl", {
// NOTE: this doesn't seem to work in FF3 with full box dimensions // NOTE: this doesn't seem to work in FF3 with full box dimensions
popup.openPopup(win, "overlap", 1, 1, false, false); popup.openPopup(win, "overlap", 1, 1, false, false);
popup.sizeTo(width - 2, height - 2); popup.sizeTo(width - 2, height - 2);
setTimeout(function () { popup.hidePopup(); }, 20); util.timeout(function () { popup.hidePopup(); }, 20);
} }
else { else {
let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound); let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound);
@@ -1888,7 +1888,7 @@ const Dactyl = Module("dactyl", {
// first time intro message // first time intro message
const firstTime = "extensions." + config.name.toLowerCase() + ".firsttime"; const firstTime = "extensions." + config.name.toLowerCase() + ".firsttime";
if (options.getPref(firstTime, true)) { if (options.getPref(firstTime, true)) {
setTimeout(function () { util.timeout(function () {
dactyl.help(); dactyl.help();
options.setPref(firstTime, false); options.setPref(firstTime, false);
}, 1000); }, 1000);
@@ -1907,7 +1907,7 @@ const Dactyl = Module("dactyl", {
// finally, read the RC file and source plugins // finally, read the RC file and source plugins
// make sourcing asynchronous, otherwise commands that open new tabs won't work // make sourcing asynchronous, otherwise commands that open new tabs won't work
setTimeout(function () { util.timeout(function () {
let extensionName = config.name.toUpperCase(); let extensionName = config.name.toUpperCase();
let init = services.get("environment").get(extensionName + "_INIT"); let init = services.get("environment").get(extensionName + "_INIT");
let rcFile = io.getRCFile("~"); let rcFile = io.getRCFile("~");

View File

@@ -409,7 +409,7 @@ const Editor = Module("editor", {
(function next() { (function next() {
textBox.style.backgroundColor = colors.shift(); textBox.style.backgroundColor = colors.shift();
if (colors.length > 0) if (colors.length > 0)
setTimeout(next, 100); util.timeout(next, 100);
})(); })();
} }

View File

@@ -74,8 +74,8 @@ const Events = Module("events", {
}; };
// load all macros // load all macros
// setTimeout needed since io. is loaded after events. // util.timeout needed since io. is loaded after events.
setTimeout(function () { this.timeout(function () {
try { try {
let dirs = io.getRuntimeDirectories("macros"); let dirs = io.getRuntimeDirectories("macros");
@@ -849,7 +849,7 @@ const Events = Module("events", {
events.feedingKeys = false; events.feedingKeys = false;
if (modes.isReplaying) { if (modes.isReplaying) {
modes.isReplaying = false; 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 else

View File

@@ -64,7 +64,7 @@ const RangeFinder = Module("rangefinder", {
find: function (pattern, backwards) { find: function (pattern, backwards) {
let str = this.bootstrap(pattern); let str = this.bootstrap(pattern);
if (!this.rangeFind.search(str)) 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; return this.rangeFind.found;
}, },
@@ -77,7 +77,7 @@ const RangeFinder = Module("rangefinder", {
else if (this.rangeFind.wrapped) else if (this.rangeFind.wrapped)
// hack needed, because wrapping causes a "scroll" event which // hack needed, because wrapping causes a "scroll" event which
// clears our command line // clears our command line
this.setTimeout(function () { this.timeout(function () {
let msg = this.rangeFind.backward ? "search hit TOP, continuing at BOTTOM" let msg = this.rangeFind.backward ? "search hit TOP, continuing at BOTTOM"
: "search hit BOTTOM, continuing at TOP"; : "search hit BOTTOM, continuing at TOP";
commandline.echo(msg, commandline.HL_WARNINGMSG, commandline.echo(msg, commandline.HL_WARNINGMSG,

View File

@@ -412,7 +412,7 @@ const Hints = Module("hints", {
// animate the disappearance of the first hint // animate the disappearance of the first hint
if (timeout && firstElem) 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"); 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 // force a possible mode change, based on whether an input field has focus
events.onFocusChange(); events.onFocusChange();
this.setTimeout(function () { this.timeout(function () {
if (modes.extended & modes.HINTS) if (modes.extended & modes.HINTS)
modes.reset(); modes.reset();
this._hintMode.action(elem, elem.href || "", this._extendedhintCount); 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) { if (this._hintNumber > 0 && this._hintNumber * 10 <= this._validHints.length) {
let timeout = options["hinttimeout"]; let timeout = options["hinttimeout"];
if (timeout > 0) 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 else // we have a unique hint
this._processHints(true); this._processHints(true);
@@ -998,7 +998,7 @@ const Hints = Module("hints", {
context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints._hintModes))]; context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints._hintModes))];
}, },
onChange: function () { modes.pop(); }, 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 }); }, { count: true });
}, },

View File

@@ -182,7 +182,7 @@ const StatusLine = Module("statusline", {
updateTabCount: function updateTabCount(delayed) { updateTabCount: function updateTabCount(delayed) {
if (dactyl.has("tabs")) { if (dactyl.has("tabs")) {
if (delayed) { if (delayed) {
this.setTimeout(function () this.updateTabCount(false), 0); this.timeout(function () this.updateTabCount(false), 0);
return; return;
} }

View File

@@ -38,7 +38,7 @@ const Tabs = Module("tabs", {
statusline.updateTabCount(true); statusline.updateTabCount(true);
this.updateSelectionHistory(); this.updateSelectionHistory();
if (options["focuscontent"]) 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), get allTabs() Array.slice(config.tabbrowser.tabContainer.childNodes),

View File

@@ -528,16 +528,15 @@ Class.prototype = {
toString: function () "[instance " + this.constructor.name + "]", toString: function () "[instance " + this.constructor.name + "]",
/** /**
* Exactly like {@see nsIDOMWindow#setTimeout}, except that it * Executes 'callback' after 'timeout' milliseconds. The value of
* preserves the value of 'this' on invocation of 'callback'. * 'this' is preserved in the invocation of 'callback'.
* *
* @param {function} callback The function to call after 'timeout' * @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'. * before calling 'callback'.
* @returns {integer} The ID of this timeout, to be passed to * @returns {nsITimer} The timer which backs this timeout.
* {@see nsIDOMWindow#clearTimeout}.
*/ */
setTimeout: function (callback, timeout) { timeout: function (callback, timeout) {
const self = this; const self = this;
let notify = { notify: function notify(timer) { callback.call(self) } }; let notify = { notify: function notify(timer) { callback.call(self) } };
let timer = services.create("timer"); let timer = services.create("timer");

View File

@@ -80,7 +80,7 @@ const Mail = Module("mail", {
return void dactyl.beep(); return void dactyl.beep();
(copy ? MsgCopyMessage : MsgMoveMessage)(folders[0]); (copy ? MsgCopyMessage : MsgMoveMessage)(folders[0]);
setTimeout(function () { util.timeout(function () {
dactyl.echomsg(count + " message(s) " + (copy ? "copied" : "moved") + " to " + folders[0].prettyName, 1); dactyl.echomsg(count + " message(s) " + (copy ? "copied" : "moved") + " to " + folders[0].prettyName, 1);
}, 100); }, 100);
}, },

View File

@@ -270,7 +270,7 @@ const Player = Module("player", {
*/ */
searchViewAgain: function searchViewAgain(reverse) { searchViewAgain: function searchViewAgain(reverse) {
function echo(str) { function echo(str) {
setTimeout(function () { this.timeout(function () {
commandline.echo(str, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE); commandline.echo(str, commandline.HL_WARNINGMSG, commandline.APPEND_TO_MESSAGES | commandline.FORCE_SINGLELINE);
}, 0); }, 0);
} }