getWindowId, getWindowById

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5675 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-12-26 20:46:48 +00:00
parent 6a4511f03f
commit ba6838b490

View File

@ -59,37 +59,6 @@
kMAX_ENTRIES : 999, kMAX_ENTRIES : 999,
kWINDOW_ID : 'UIOperationGlobalHistoryWindowID', kWINDOW_ID : 'UIOperationGlobalHistoryWindowID',
_doingUndo : false,
_tables : tables,
initialized : false,
init : function()
{
var targets = this.WindowMediator.getZOrderDOMWindowEnumerator('navigator:browser', true);
while (targets.hasMoreElements())
{
let target = targets.getNext().QueryInterface(Ci.nsIDOMWindowInternal);
if (
'piro.sakura.ne.jp' in target &&
'operationHistory' in target['piro.sakura.ne.jp'] &&
target['piro.sakura.ne.jp'].operationHistory.initialized
) {
this._tables = target['piro.sakura.ne.jp'].operationHistory._tables;
break;
}
}
window.addEventListener('unload', this, false);
this.initialized = true;
},
destroy : function()
{
window.removeEventListener('unload', this, false);
},
addEntry : function() addEntry : function()
{ {
if (this._doingUndo) if (this._doingUndo)
@ -156,6 +125,62 @@
return true; return true;
}, },
getWindowId : function(aWindow)
{
var windowId = this.SessionStore.getWindowValue(aWindow, this.kWINDOW_ID);
if (!windowId) {
windowId = 'window-'+Date.now()+parseInt(Math.random() * 65000);
this.SessionStore.setWindowValue(aWindow, this.kWINDOW_ID, windowId);
}
return windowId;
},
getWindowById : function(aId)
{
var targets = this.WindowMediator.getZOrderDOMWindowEnumerator('navigator:browser', true);
while (targets.hasMoreElements())
{
let target = targets.getNext().QueryInterface(Ci.nsIDOMWindowInternal);
if (aId == this.SessionStore.getWindowValue(target, this.kWINDOW_ID))
return target;
}
return null;
},
/* PRIVATE METHODS */
_doingUndo : false,
_tables : tables,
initialized : false,
init : function()
{
var targets = this.WindowMediator.getZOrderDOMWindowEnumerator('navigator:browser', true);
while (targets.hasMoreElements())
{
let target = targets.getNext().QueryInterface(Ci.nsIDOMWindowInternal);
if (
'piro.sakura.ne.jp' in target &&
'operationHistory' in target['piro.sakura.ne.jp'] &&
target['piro.sakura.ne.jp'].operationHistory.initialized
) {
this._tables = target['piro.sakura.ne.jp'].operationHistory._tables;
break;
}
}
window.addEventListener('unload', this, false);
this.initialized = true;
},
destroy : function()
{
window.removeEventListener('unload', this, false);
},
_dispatchEvent : function(aOptions) _dispatchEvent : function(aOptions)
{ {
var d = aOptions.window ? aOptions.window.document : document ; var d = aOptions.window ? aOptions.window.document : document ;
@ -182,11 +207,7 @@
if (!name) if (!name)
name = w ? 'window' : 'global' ; name = w ? 'window' : 'global' ;
var windowId = this.SessionStore.getWindowValue(window, this.kWINDOW_ID); var windowId = this.getWindowId(window);
if (!windowId) {
windowId = 'window-'+Date.now()+parseInt(Math.random() * 65000);
this.SessionStore.setWindowValue(window, this.kWINDOW_ID, windowId);
}
var tableName = w ? encodeURIComponent(name)+'::'+windowId : encodeURIComponent(name) ; var tableName = w ? encodeURIComponent(name)+'::'+windowId : encodeURIComponent(name) ;
if (!(tableName in this._tables)) { if (!(tableName in this._tables)) {
@ -206,21 +227,9 @@
}; };
}, },
_getWindowById : function(aId)
{
var targets = this.WindowMediator.getZOrderDOMWindowEnumerator('navigator:browser', true);
while (targets.hasMoreElements())
{
let target = targets.getNext().QueryInterface(Ci.nsIDOMWindowInternal);
if (aId == this.SessionStore.getWindowValue(target, this.kWINDOW_ID))
return target;
}
return null;
},
_deleteWindowTables : function() _deleteWindowTables : function()
{ {
var id = this.SessionStore.getWindowValue(window, this.kWINDOW_ID); var id = this.getWindowId(window);
if (!id) return; if (!id) return;
var removedTables = []; var removedTables = [];