Bug 690644 - Don't specify background and text colors by default when composing a message. r=mkmelin DONTBUILD
authorRyan <palswim+mozilla.org@palswim.net> and Jorg K <jorgk@jorgk.com>
Thu, 19 Oct 2017 12:32:22 -0700
changeset 32758 29f023e0da21005225cc793b93e50a95cf6d0575
parent 32757 2dd2b075db9e3d3643f41247858f5e92ded8d687
child 32759 5bf8cf04b0042058f13bffad5827b38473ae8155
push id2343
push userclokep@gmail.com
push dateMon, 10 Dec 2018 21:37:21 +0000
treeherdercomm-beta@a0750c375f71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs690644
Bug 690644 - Don't specify background and text colors by default when composing a message. r=mkmelin DONTBUILD
mail/components/compose/content/MsgComposeCommands.js
mail/components/preferences/compose.inc.xul
mail/components/preferences/compose.js
mail/locales/en-US/chrome/messenger/preferences/compose.dtd
mailnews/mailnews.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -6276,46 +6276,43 @@ function AddRecipient(aRecipientType, aA
 }
 
 // Public method called by the contants sidebar.
 function AddRecipientsArray(aRecipientType, aAddressArray) {
   awAddRecipientsArray(aRecipientType, aAddressArray);
 }
 
 function loadHTMLMsgPrefs() {
-  var fontFace;
-  var fontSize;
-  var textColor;
-  var bgColor;
-
   try {
-    fontFace = getPref("msgcompose.font_face", true);
+    let fontFace = getPref("msgcompose.font_face", true);
     doStatefulCommand("cmd_fontFace", fontFace);
   } catch (e) {}
 
   try {
-    fontSize = getPref("msgcompose.font_size");
+    let fontSize = getPref("msgcompose.font_size");
     EditorSetFontSize(fontSize);
   } catch (e) {}
 
-  var bodyElement = GetBodyElement();
+  let bodyElement = GetBodyElement();
+
+  let useDefault = getPref("msgcompose.default_colors");
 
   try {
-    textColor = getPref("msgcompose.text_color");
-    if (!bodyElement.getAttribute("text")) {
+    let textColor = (useDefault ? "" : getPref("msgcompose.text_color"));
+    if ((!bodyElement.getAttribute("text")) && textColor) {
       bodyElement.setAttribute("text", textColor);
       gDefaultTextColor = textColor;
       document.getElementById("cmd_fontColor").setAttribute("state", textColor);
       onFontColorChange();
     }
   } catch (e) {}
 
   try {
-    bgColor = getPref("msgcompose.background_color");
-    if (!bodyElement.getAttribute("bgcolor")) {
+    let bgColor = (useDefault ? "" : getPref("msgcompose.background_color"));
+    if ((!bodyElement.getAttribute("bgcolor")) && bgColor) {
       bodyElement.setAttribute("bgcolor", bgColor);
       gDefaultBackgroundColor = bgColor;
       document.getElementById("cmd_backgroundColor").setAttribute("state", bgColor);
       onBackgroundColorChange();
     }
   } catch (e) {}
 }
 
--- a/mail/components/preferences/compose.inc.xul
+++ b/mail/components/preferences/compose.inc.xul
@@ -22,16 +22,17 @@
                   name="ldap_2.autoComplete.useDirectory"
                   onchange="gComposePane.enableAutocomplete();" type="bool"/>
       <preference id="ldap_2.autoComplete.directoryServer" name="ldap_2.autoComplete.directoryServer" type="string"/>
       <preference id="pref.ldap.disable_button.edit_directories"
                   name="pref.ldap.disable_button.edit_directories" type="bool"/>
       <preference id="mail.collect_email_address_outgoing" name="mail.collect_email_address_outgoing" type="bool"/>
       <preference id="mail.collect_addressbook" name="mail.collect_addressbook" type="string"/>
       <preference id="spellchecker.dictionary"  name="spellchecker.dictionary"   type="unichar"/>
+      <preference id="msgcompose.default_colors" name="msgcompose.default_colors" type="bool"/>
       <preference id="msgcompose.font_face"      name="msgcompose.font_face" type="string"/>
       <preference id="msgcompose.font_size"      name="msgcompose.font_size" type="string"/>
       <preference id="msgcompose.text_color"     name="msgcompose.text_color" type="string"/>
       <preference id="msgcompose.background_color" name="msgcompose.background_color" type="string"/>
       <preference id="mail.compose.attachment_reminder"
                   name="mail.compose.attachment_reminder"
                   type="bool"/>
       <preference id="mail.compose.default_to_paragraph"
@@ -39,16 +40,18 @@
                   type="bool"/>
     </preferences>
 
     <commandset id="compositionGeneralCommandSet">
       <command id="cmd_toggleAutosave"
                oncommand="gComposePane.updateAutosave();"/>
       <command id="cmd_toggleAttachmentCheck"
                oncommand="gComposePane.updateAttachmentCheck();"/>
+      <command id="cmd_toggleUseReaderDefaults"
+               oncommand="gComposePane.updateUseReaderDefaults();"/>
     </commandset>
 
     <tabbox id="composePrefs" flex="1" onselect="gComposePane.tabSelectionChanged();">
       <tabs id="composePrefsTabs">
         <tab id="generalTab" label="&itemGeneral.label;"/>
         <tab id="addressingTab" label="&itemAutoComplete.label;"/>
         <tab id="spellingTab" label="&itemSpellCheck.label;"/>
       </tabs>
@@ -130,23 +133,39 @@
                   <menuitem value="xx-large" label="&size-hugeCmd.label;"/>
                 </menupopup>
               </menulist>
             </hbox>
 
             <separator class="thin"/>
 
             <hbox align="center">
-              <label control="textColorButton" value="&fontColor.label;" accesskey="&fontColor.accesskey;"/>
+              <checkbox id="useReaderDefaults"
+                        label="&useReaderDefaults.label;"
+                        accesskey="&useReaderDefaults.accesskey;"
+                        preference="msgcompose.default_colors"
+                        command="cmd_toggleUseReaderDefaults"/>
+            </hbox>
+            <hbox align="center" class="indent">
+              <label id="textColorLabel"
+                     control="textColorButton"
+                     value="&fontColor.label;"
+                     accesskey="&fontColor.accesskey;"/>
               <html:input type="color" id="textColorButton" preference="msgcompose.text_color"/>
               <separator orient="vertical" class="thin"/>
-              <label control="backgroundColorButton" value="&bgColor.label;" accesskey="&bgColor.accesskey;"/>
+              <label id="backgroundColorLabel"
+                     control="backgroundColorButton"
+                     value="&bgColor.label;"
+                     accesskey="&bgColor.accesskey;"/>
               <html:input type="color" id="backgroundColorButton" preference="msgcompose.background_color"/>
+            </hbox>
+            <hbox align="center">
               <spacer flex="1"/>
-              <button label="&restoreHTMLDefaults.label;" accesskey="&restoreHTMLDefaults.accesskey;"
+              <button label="&restoreHTMLDefaults.label;"
+                      accesskey="&restoreHTMLDefaults.accesskey;"
                       oncommand="gComposePane.restoreHTMLDefaults();"/>
             </hbox>
 
             <separator class="thin"/>
 
             <hbox align="center">
               <checkbox id="defaultToParagraph"
                         label="&defaultToParagraph.label;"
--- a/mail/components/preferences/compose.js
+++ b/mail/components/preferences/compose.js
@@ -14,16 +14,18 @@ var gComposePane = {
     this.enableAutocomplete();
 
     this.initLanguageMenu();
 
     this.populateFonts();
 
     this.updateAutosave();
 
+    this.updateUseReaderDefaults();
+
     this.updateAttachmentCheck();
 
     this.updateEmailCollection();
 
     this.initAbDefaultStartupDir();
 
     this.setButtonColors();
 
@@ -53,16 +55,28 @@ var gComposePane = {
                     "resizable=no");
   },
 
   updateAutosave() {
     this.enableElement(document.getElementById("autoSaveInterval"),
       document.getElementById("autoSave").checked);
   },
 
+  updateUseReaderDefaults() {
+    let useReaderDefaultsChecked = document.getElementById("useReaderDefaults").checked;
+    this.enableElement(document.getElementById("textColorLabel"),
+      !useReaderDefaultsChecked);
+    this.enableElement(document.getElementById("backgroundColorLabel"),
+      !useReaderDefaultsChecked);
+    this.enableElement(document.getElementById("textColorButton"),
+      !useReaderDefaultsChecked);
+    this.enableElement(document.getElementById("backgroundColorButton"),
+      !useReaderDefaultsChecked);
+  },
+
   updateAttachmentCheck() {
     this.enableElement(document.getElementById("attachment_reminder_button"),
       document.getElementById("attachment_reminder_label").checked);
   },
 
   updateEmailCollection() {
     this.enableElement(document.getElementById("localDirectoriesList"),
       document.getElementById("emailCollectionOutgoing").checked);
@@ -197,16 +211,21 @@ var gComposePane = {
      try {
        document.getElementById("msgcompose.text_color").reset();
      } catch (ex) {}
 
      try {
        document.getElementById("msgcompose.background_color").reset();
      } catch (ex) {}
 
+     try {
+       document.getElementById("msgcompose.default_colors").reset();
+     } catch (ex) {}
+
+     this.updateUseReaderDefaults();
      this.setButtonColors();
   },
 
   startupDirListener: {
     inited: false,
     domain: "mail.addr_book.view.startupURI",
     observe(subject, topic, prefName) {
       if (topic != "nsPref:changed")
--- a/mail/locales/en-US/chrome/messenger/preferences/compose.dtd
+++ b/mail/locales/en-US/chrome/messenger/preferences/compose.dtd
@@ -15,16 +15,18 @@
 <!ENTITY addExtension.label                   "add extension to file name">
 <!ENTITY addExtension.accesskey               "e">
 
 <!ENTITY htmlComposeHeader.label              "HTML">
 <!ENTITY font.label                           "Font:">
 <!ENTITY font.accesskey                       "n">
 <!ENTITY size.label                           "Size:">
 <!ENTITY size.accesskey                       "z">
+<!ENTITY useReaderDefaults.label              "Use reader's default colors">
+<!ENTITY useReaderDefaults.accesskey          "d">
 <!ENTITY fontColor.label                      "Text Color:">
 <!ENTITY fontColor.accesskey                  "T">
 <!ENTITY bgColor.label                        "Background Color:">
 <!ENTITY bgColor.accesskey                    "B">
 <!ENTITY restoreHTMLDefaults.label            "Restore Defaults">
 <!ENTITY restoreHTMLDefaults.accesskey        "R">
 <!ENTITY defaultToParagraph.label             "Use Paragraph format instead of Body Text by default">
 <!ENTITY defaultToParagraph.accesskey         "P">
--- a/mailnews/mailnews.js
+++ b/mailnews/mailnews.js
@@ -814,16 +814,19 @@ pref("mailnews.display_reply_tag_colors_
 
 //default null headers
 //example "X-Warn: XReply", list of hdrs separated by ": "
 pref("mailnews.customHeaders", "");
 
 // default msg compose font prefs
 pref("msgcompose.font_face",                "");
 pref("msgcompose.font_size",                "medium");
+// If true, let the user agent use default colors (don't set text_color and
+// background_color on the message body).
+pref("msgcompose.default_colors",           true);
 pref("msgcompose.text_color",               "#000000");
 pref("msgcompose.background_color",         "#FFFFFF");
 
 // When there is no disclosed recipients (only bcc), we should address the message to empty group
 // to prevent some mail server to disclose the bcc recipients
 pref("mail.compose.add_undisclosed_recipients", true);
 
 pref("mail.compose.dontWarnMail2Newsgroup", false);