Bug 609877 Don't access DOM elements before the document has loaded (prerequisite for lightweight theme support) r=Mnyromyr
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Mon, 08 Nov 2010 23:35:42 +0000
changeset 6665 5970a061c13568c45a2e998d077a0b4488937449
parent 6664 1634e5c4c0bc16de48d8f70c396cc58b9f4f5f9e
child 6670 75a27f4896159e652ee612565af4640912bb1562
push idunknown
push userunknown
push dateunknown
reviewersMnyromyr
bugs609877
Bug 609877 Don't access DOM elements before the document has loaded (prerequisite for lightweight theme support) r=Mnyromyr
suite/mailnews/compose/MsgComposeCommands.js
suite/mailnews/mail3PaneWindowCommands.js
suite/mailnews/mailWindowOverlay.js
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -54,18 +54,18 @@ const mozISpellCheckingEngine = Componen
  * In order to distinguish clearly globals that are initialized once when js load (static globals) and those that need to be
  * initialize every time a compose window open (globals), I (ducarroz) have decided to prefix by s... the static one and
  * by g... the other one. Please try to continue and repect this rule in the future. Thanks.
  */
 /**
  * static globals, need to be initialized only once
  */
 var sMsgComposeService = Components.classes["@mozilla.org/messengercompose;1"].getService(Components.interfaces.nsIMsgComposeService);
-var sComposeMsgsBundle = document.getElementById("bundle_composeMsgs");
-var sBrandBundle = document.getElementById("brandBundle");
+var sComposeMsgsBundle;
+var sBrandBundle;
 
 var sPrefs = null;
 var sPrefBranchInternal = null;
 var sOther_headers = "";
 
 var sAccountManagerDataSource = null;
 var sRDF = null;
 var sNameProperty = null;
@@ -1453,16 +1453,19 @@ function WizCallback(state)
   {
     // The account wizard is still closing so we can't close just yet
     setTimeout(MsgComposeCloseWindow, 0, false); // Don't recycle a bogus window
   }
 }
 
 function ComposeLoad()
 {
+  sComposeMsgsBundle = document.getElementById("bundle_composeMsgs");
+  sBrandBundle = document.getElementById("brandBundle");
+
   // First get the preferences service
   try {
     var prefService = Components.classes["@mozilla.org/preferences-service;1"]
                               .getService(Components.interfaces.nsIPrefService);
     sPrefs = prefService.getBranch(null);
     sPrefBranchInternal = sPrefs.QueryInterface(Components.interfaces.nsIPrefBranch2);
   }
   catch (ex) {
--- a/suite/mailnews/mail3PaneWindowCommands.js
+++ b/suite/mailnews/mail3PaneWindowCommands.js
@@ -35,17 +35,16 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
-var gMessengerBundle = document.getElementById("bundle_messenger");
 
 // Controller object for folder pane
 var FolderPaneController =
 {
    supportsCommand: function(command)
 	{
 		switch ( command )
 		{
--- a/suite/mailnews/mailWindowOverlay.js
+++ b/suite/mailnews/mailWindowOverlay.js
@@ -2634,18 +2634,16 @@ var gMessageNotificationBar =
   mBarFlagValues: [
                     0, // for no msgNotificationBar
                     1, // 1 << (kMsgNotificationPhishingBar - 1)
                     2, // 1 << (kMsgNotificationJunkBar - 1)
                     4, // 1 << (kMsgNotificationRemoteImages - 1)
                     8  // 1 << (kMsgNotificationMDN - 1)
                   ],
 
-  mMsgNotificationBar: document.getElementById('msgNotificationBar'),
-
   setJunkMsg: function(aMsgHdr)
   {
     var isJunk = false;
   
     if (aMsgHdr) 
     {
       var junkScore = aMsgHdr.getStringProperty("junkscore"); 
       isJunk = ((junkScore != "") && (junkScore != "0"));
@@ -2682,32 +2680,34 @@ var gMessageNotificationBar =
   {
     this.mdnGenerator = aMdnGenerator;
     this.updateMsgNotificationBar(kMsgNotificationMDN, true);
   },
 
   clearMsgNotifications: function()
   {
     this.mBarStatus = 0;
-    this.mMsgNotificationBar.selectedIndex = 0;
-    this.mMsgNotificationBar.collapsed = true;
+    var msgNotificationBar = document.getElementById('msgNotificationBar');
+    msgNotificationBar.selectedIndex = 0;
+    msgNotificationBar.collapsed = true;
   },
 
   // private method used to set our message notification deck to the correct value...
   updateMsgNotificationBar: function(aIndex, aSet)
   {
     var chunk = this.mBarFlagValues[aIndex];
     var status = aSet ? this.mBarStatus | chunk : this.mBarStatus & ~chunk;
     this.mBarStatus = status;
 
     // the phishing message takes precedence over the junk message
     // which takes precedence over the remote content message
-    this.mMsgNotificationBar.selectedIndex = this.mBarFlagValues.indexOf(status & -status);
-
-    this.mMsgNotificationBar.collapsed = !status;
+    var msgNotificationBar = document.getElementById('msgNotificationBar');
+    msgNotificationBar.selectedIndex = this.mBarFlagValues.indexOf(status & -status);
+
+    msgNotificationBar.collapsed = !status;
   },
 
   /**
    * @param aFlag  kMsgNotificationPhishingBar, kMsgNotificationJunkBar, or
    *               kMsgNotificationRemoteImages
    * @return true if aFlag is currently set for the loaded message
    */
   isFlagSet: function(aFlag)