Bug 321783 - Unneeded save message question for empty compose window (when the window isn't a cached one) due to async messageQuotes.css load happening after we reset the editor's dirty state, r=Standard8
authorPhil Ringnalda <philringnalda@gmail.com>
Fri, 19 Jun 2009 20:01:26 -0700
changeset 2896 6bcbb9a88f88db5a99c1b13692a9ae8df098ab0c
parent 2895 6f5baa0cddd240bb7c0ecc6e9f57e78adc94b90a
child 2897 7a767870e14eb6db047fdb0e5dbcce81fdbab2db
push idunknown
push userunknown
push dateunknown
reviewersStandard8
bugs321783
Bug 321783 - Unneeded save message question for empty compose window (when the window isn't a cached one) due to async messageQuotes.css load happening after we reset the editor's dirty state, r=Standard8
mail/base/content/composerOverlay.css
mail/components/compose/content/MsgComposeCommands.js
mail/themes/gnomestripe/mail/messageQuotes.css
mail/themes/qute/mail/messageQuotes.css
--- a/mail/base/content/composerOverlay.css
+++ b/mail/base/content/composerOverlay.css
@@ -29,16 +29,20 @@
  * use your version of this file under the terms of the MPL, indicate your
  * 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 ***** */
 
+/* Because this sheet is loaded synchronously while the user is waiting for the
+   compose window to appear, it must not @import a ton of other things, and
+   especially must not trigger network access. */
+
 .moz-email-headers-table,
 .moz-email-headers-table > tbody > tr > th,
 .moz-email-headers-table > tbody > tr > td,
 blockquote[type=cite] table,
 blockquote[type=cite] table > tbody > tr > th,
 blockquote[type=cite] table > tbody > tr > td {
   border: 1px solid transparent !important;
 }
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -1410,17 +1410,22 @@ var gMsgEditorCreationObserver =
   observe: function(aSubject, aTopic, aData)
   {
     if (aTopic == "obs_documentCreated")
     {
       var editor = GetCurrentEditor();
       if (editor && GetCurrentCommandManager() == aSubject)
       {
         var editorStyle = editor.QueryInterface(Components.interfaces.nsIEditorStyleSheets);
-        editorStyle.addStyleSheet("chrome://messenger/skin/messageQuotes.css");
+        // We use addOverrideStyleSheet rather than addStyleSheet so that we get
+        // a synchronous load, rather than having a late-finishing async load
+        // mark our editor as modified when the user hasn't typed anything yet,
+        // but that means the sheet must not @import slow things, especially
+        // not over the network.
+        editorStyle.addOverrideStyleSheet("chrome://messenger/skin/messageQuotes.css");
         InitEditor();
       }
       // Now that we know this document is an editor, update commands now if
       // the document has focus, or next time it receives focus via
       // CommandUpdate_MsgCompose()
       if (gLastWindowToHaveFocus == document.commandDispatcher.focusedWindow)
         updateComposeItems();
       else
@@ -3566,16 +3571,21 @@ function AutoSave()
 
   gAutoSaveTimeout = setTimeout(AutoSave, gAutoSaveInterval);
 }
 
 function InitEditor()
 {
   var editor = GetCurrentEditor();
   editor.QueryInterface(nsIEditorStyleSheets);
+  // We use addOverrideStyleSheet rather than addStyleSheet so that we get
+  // a synchronous load, rather than having a late-finishing async load
+  // mark our editor as modified when the user hasn't typed anything yet,
+  // but that means the sheet must not @import slow things, especially
+  // not over the network.
   editor.addOverrideStyleSheet("chrome://messenger/content/composerOverlay.css");
   gMsgCompose.initEditor(editor, window.content);
 
   InlineSpellCheckerUI.init(editor);
   enableInlineSpellCheck(getPref("mail.spellcheck.inline"));
   document.getElementById('menu_inlineSpellCheck').setAttribute('disabled', !InlineSpellCheckerUI.canSpellCheck);
 }
 
--- a/mail/themes/gnomestripe/mail/messageQuotes.css
+++ b/mail/themes/gnomestripe/mail/messageQuotes.css
@@ -1,8 +1,12 @@
+/* Because this sheet is loaded synchronously while the user is waiting for the
+   compose window to appear, it must not @import a ton of other things, and
+   especially must not trigger network access. */
+
 /* ===== messageQuotes.css =================================================
   == Shared styles such as block quote colors and signature style
   == between the message body during
   == message display and the mail editor instance for mail compose.
   ======================================================================= */
 
 /* ::::: signature ::::: */
 
--- a/mail/themes/qute/mail/messageQuotes.css
+++ b/mail/themes/qute/mail/messageQuotes.css
@@ -1,8 +1,12 @@
+/* Because this sheet is loaded synchronously while the user is waiting for the
+   compose window to appear, it must not @import a ton of other things, and
+   especially must not trigger network access. */
+
 /* ===== messageQuotes.css =================================================
   == Shared styles such as block quote colors and signature style
   == between the message body during
   == message display and the mail editor instance for mail compose.
   ======================================================================= */
 
 /* ::::: signature ::::: */