mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 574117 - Page content never updates [r=mfinkle]
This commit is contained in:
parent
4900562688
commit
e9b7dc15f4
@ -210,6 +210,72 @@ let Util = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper class to nsITimer that adds a little more pizazz. Callback can be an
|
||||
* object with a notify method or a function.
|
||||
*/
|
||||
Util.Timeout = function(aCallback) {
|
||||
this._callback = aCallback;
|
||||
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
|
||||
this._active = false;
|
||||
}
|
||||
|
||||
Util.Timeout.prototype = {
|
||||
/** Timer callback. Don't call this manually. */
|
||||
notify: function notify() {
|
||||
this._active = false;
|
||||
if (this._callback.notify)
|
||||
this._callback.notify();
|
||||
else
|
||||
this._callback.apply(null);
|
||||
},
|
||||
|
||||
/** Do the callback once. Cancels other timeouts on this object. */
|
||||
once: function once(aDelay, aCallback) {
|
||||
if (aCallback)
|
||||
this._callback = aCallback;
|
||||
this.clear();
|
||||
this._timer.initWithCallback(this, aDelay, this._timer.TYPE_ONE_SHOT);
|
||||
this._active = true;
|
||||
return this;
|
||||
},
|
||||
|
||||
/** Do the callback every aDelay msecs. Cancels other timeouts on this object. */
|
||||
interval: function interval(aDelay, aCallback) {
|
||||
if (aCallback)
|
||||
this._callback = aCallback;
|
||||
this.clear();
|
||||
this._timer.initWithCallback(this, aDelay, this._timer.TYPE_REPEATING_SLACK);
|
||||
this._active = true;
|
||||
return this;
|
||||
},
|
||||
|
||||
/** Clear any pending timeouts. */
|
||||
clear: function clear() {
|
||||
if (this._active) {
|
||||
this._timer.cancel();
|
||||
this._active = false;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/** If there is a pending timeout, call it and cancel the timeout. */
|
||||
flush: function flush() {
|
||||
if (this._active) {
|
||||
this.clear();
|
||||
this.notify();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/** Return true iff we are waiting for a callback. */
|
||||
isPending: function isPending() {
|
||||
return this._active;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cache of commonly used elements.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user