ライブラリ更新
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6783 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
767e0056ee
commit
5236d46f18
@ -41,7 +41,8 @@ function setTimeout()
|
|||||||
return (new Timer(
|
return (new Timer(
|
||||||
callback,
|
callback,
|
||||||
timeout,
|
timeout,
|
||||||
Ci.nsITimer.TYPE_ONE_SHOT
|
Ci.nsITimer.TYPE_ONE_SHOT,
|
||||||
|
getOwnerWindowFromCaller(arguments.callee.caller)
|
||||||
)).id;
|
)).id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +64,8 @@ function setInterval()
|
|||||||
return (new Timer(
|
return (new Timer(
|
||||||
callback,
|
callback,
|
||||||
interval,
|
interval,
|
||||||
Ci.nsITimer.TYPE_REPEATING_SLACK
|
Ci.nsITimer.TYPE_REPEATING_SLACK,
|
||||||
|
getOwnerWindowFromCaller(arguments.callee.caller)
|
||||||
)).id;
|
)).id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,10 +75,11 @@ function clearInterval(aId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function Timer(aCallback, aTime, aType) {
|
function Timer(aCallback, aTime, aType, aOwner) {
|
||||||
this.finished = false;
|
this.finished = false;
|
||||||
this.callback = aCallback;
|
this.callback = aCallback;
|
||||||
this.type = aType;
|
this.type = aType;
|
||||||
|
this.owner = aOwner;
|
||||||
this.init(aTime);
|
this.init(aTime);
|
||||||
|
|
||||||
Timer.instances[this.id] = this;
|
Timer.instances[this.id] = this;
|
||||||
@ -104,6 +107,15 @@ Timer.prototype = {
|
|||||||
{
|
{
|
||||||
if (aTopic != 'timer-callback') return;
|
if (aTopic != 'timer-callback') return;
|
||||||
|
|
||||||
|
if (this.owner && this.owner.closed) {
|
||||||
|
dump('jstimer.jsm:'+
|
||||||
|
' timer is stopped because the owner window was closed.\n'+
|
||||||
|
' type: '+(this.type == Ci.nsITimer.TYPE_ONE_SHOT ? 'TYPE_ONE_SHOT' : 'TYPE_REPEATING_SLACK' )+'\n'+
|
||||||
|
' callback: '+(this.callback.source || this.callback)+'\n');
|
||||||
|
this.cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof this.callback == 'function')
|
if (typeof this.callback == 'function')
|
||||||
this.callback();
|
this.callback();
|
||||||
else
|
else
|
||||||
@ -133,3 +145,15 @@ function getGlobal()
|
|||||||
{
|
{
|
||||||
return (function() { return this; })();
|
return (function() { return this; })();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getOwnerWindowFromCaller(aCaller)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
var global = aCaller.valueOf.call(null);
|
||||||
|
if (global && global instanceof Ci.nsIDOMWindow)
|
||||||
|
return global;
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user