Bug 647654. (Av1a) smileApplication.js: Bind '_event()' once for all. r=neil.
authorSerge Gautherie <sgautherie.bz@free.fr>
Tue, 29 May 2012 20:28:34 +0200
changeset 10314 67501405df7b5ad4fc385598318b5f37a1fc6e21
parent 10313 49b9049983eb124eaf5230ea37bf04af7609744e
child 10315 8bcff760879f6f5177d7f62505946b754150c404
push id7812
push usersgautherie.bz@free.fr
push dateTue, 29 May 2012 18:29:22 +0000
treeherdercomm-central@67501405df7b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs647654
Bug 647654. (Av1a) smileApplication.js: Bind '_event()' once for all. r=neil.
suite/smile/src/smileApplication.js
--- 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;
     }