Bug 627851 - PreferencesView._delayedInit is not delayed enough [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 27 Jan 2011 09:36:22 -0800
changeset 67314 fd36b84eb5444db86a2e26acb0d8ff62062590d7
parent 67313 ab7dc52a489691823c6faf0bc249b7ed8da1f9d6
child 67315 343f213b87e33a319399cba3cca9ef2710f5b150
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs627851
Bug 627851 - PreferencesView._delayedInit is not delayed enough [r=mfinkle]
mobile/chrome/content/browser-ui.js
mobile/chrome/content/preferences.js
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -738,18 +738,24 @@ var BrowserUI = {
   showPanel: function showPanel(aPage) {
     if (this.activePanel)
       this.activePanel = null;
 
     Elements.panelUI.left = 0;
     Elements.panelUI.hidden = false;
     Elements.contentShowing.setAttribute("disabled", "true");
 
-    if (aPage != undefined)
+    if (aPage) {
       this.switchPane(aPage);
+    } else {
+      // Fire a "select" event anyway so listeners know when the panel is opened.
+      let event = document.createEvent("Events");
+      event.initEvent("select", true, true);
+      document.getElementById("panel-items").dispatchEvent(event);
+    }
   },
 
   hidePanel: function hidePanel() {
     if (!this.isPanelVisible())
       return;
     Elements.panelUI.hidden = true;
     Elements.contentShowing.removeAttribute("disabled");
     this.blurFocusedElement();
--- a/mobile/chrome/content/preferences.js
+++ b/mobile/chrome/content/preferences.js
@@ -36,17 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 var PreferencesView = {
   _currentLocale: null,
   _languages: null,
   _msg: null,
   _restartCount: 0,
 
-  _messageActions: function ev__messageActions(aData) {
+  _messageActions: function pv__messageActions(aData) {
     if (aData == "prefs-restart-app") {
       // Notify all windows that an application quit has been requested
       var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
       Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart");
 
       // If nothing aborted, quit the app
       if (cancelQuit.data == false) {
         let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
@@ -102,23 +102,25 @@ var PreferencesView = {
       return;
 
     this._msg = document.getElementById("prefs-messages");
 
     let self = this;
     let panels = document.getElementById("panel-items");
     panels.addEventListener("select",
                             function(aEvent) {
+                              if (aEvent.target != panels)
+                                return;
                               if (panels.selectedPanel.id == "prefs-container")
                                 self._delayedInit();
                             },
                             false);
   },
 
-  _delayedInit: function ev__delayedInit() {
+  _delayedInit: function pv__delayedInit() {
     if (this._languages)
       return;
 
     this._languages = document.getElementById("prefs-languages");
     this._loadLocales();
 
     this._loadHomePage();
   },