Bug 647654. (Av1a) smileApplication.js: Bind '_event()' once for all. r=neil.
--- a/suite/smile/src/smileApplication.js
+++ b/suite/smile/src/smileApplication.js
@@ -117,16 +117,18 @@ var Utilities = {
//=================================================
// Window implementation
function Window(aWindow) {
this._window = aWindow;
this._tabbrowser = aWindow.getBrowser();
this._events = new Events();
this._cleanup = {};
+ // Define '_event()' as bound once for all.
+ this._event = this.__event.bind(this);
this._watch("TabOpen");
this._watch("TabMove");
this._watch("TabClose");
this._watch("TabSelect");
gShutdown.push(this._shutdown.bind(this));
}
@@ -136,24 +138,24 @@ Window.prototype = {
},
/*
* Helper used to setup event handlers on the XBL element. Note that the events
* are actually dispatched to tabs, so we capture them.
*/
_watch : function win_watch(aType) {
this._tabbrowser.tabContainer.addEventListener(aType,
- this._cleanup[aType] = this._event.bind(this),
+ this._cleanup[aType] = this._event,
true);
},
/*
* Helper event callback used to redirect events made on the XBL element
*/
- _event : function win_event(aEvent) {
+ __event : function win_event(aEvent) {
this._events.dispatch(aEvent.type, new BrowserTab(this, aEvent.originalTarget));
},
get tabs() {
var tabs = [];
var tabNodes = this._tabbrowser.tabs;
for (var i = 0; i < tabNodes.length; i++)
tabs.push(new BrowserTab(this, tabNodes[i]));
@@ -187,16 +189,18 @@ Window.prototype = {
function BrowserTab(aSMILEWindow, aTab) {
this._window = aSMILEWindow;
this._tabbrowser = aSMILEWindow._tabbrowser;
this._browser = aTab.linkedBrowser;
this._tab = aTab;
this._events = new Events();
this._cleanup = {};
+ // Define '_event()' as bound once for all.
+ this._event = this.__event.bind(this);
this._watch("load");
gShutdown.push(this._shutdown.bind(this));
}
BrowserTab.prototype = {
get uri() {
return this._browser.currentURI;
@@ -223,24 +227,24 @@ BrowserTab.prototype = {
return this._browser.contentDocument;
},
/*
* Helper used to setup event handlers on the XBL element
*/
_watch : function bt_watch(aType) {
this._browser.addEventListener(aType,
- this._cleanup[aType] = this._event.bind(this),
+ this._cleanup[aType] = this._event,
true);
},
/*
* Helper event callback used to redirect events made on the XBL element
*/
- _event : function bt_event(aEvent) {
+ __event : function bt_event(aEvent) {
if (aEvent.type == "load") {
if (!(aEvent.originalTarget instanceof Components.interfaces.nsIDOMDocument))
return;
if (aEvent.originalTarget.defaultView instanceof Components.interfaces.nsIDOMWindow &&
aEvent.originalTarget.defaultView.frameElement)
return;
}