ライブラリ更新

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6783 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-06-28 16:04:04 +00:00
parent 767e0056ee
commit 5236d46f18

View File

@ -41,7 +41,8 @@ function setTimeout()
return (new Timer(
callback,
timeout,
Ci.nsITimer.TYPE_ONE_SHOT
Ci.nsITimer.TYPE_ONE_SHOT,
getOwnerWindowFromCaller(arguments.callee.caller)
)).id;
}
@ -63,7 +64,8 @@ function setInterval()
return (new Timer(
callback,
interval,
Ci.nsITimer.TYPE_REPEATING_SLACK
Ci.nsITimer.TYPE_REPEATING_SLACK,
getOwnerWindowFromCaller(arguments.callee.caller)
)).id;
}
@ -73,10 +75,11 @@ function clearInterval(aId)
}
function Timer(aCallback, aTime, aType) {
function Timer(aCallback, aTime, aType, aOwner) {
this.finished = false;
this.callback = aCallback;
this.type = aType;
this.owner = aOwner;
this.init(aTime);
Timer.instances[this.id] = this;
@ -104,6 +107,15 @@ Timer.prototype = {
{
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')
this.callback();
else
@ -133,3 +145,15 @@ function getGlobal()
{
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;
}