Bug 1658999 - Fix variable width and fixed width in message compose window. r=mkmelin, jorgk DONTBUILD

This commit is contained in:
Khushil Mistry 2020-08-16 13:25:12 +03:00
Родитель 84dd581a64
Коммит 38c93f8c99
8 изменённых файлов: 21 добавлений и 25 удалений

Просмотреть файл

@ -121,7 +121,7 @@ var MailMigrator = {
_migrateUI() {
// The code for this was ported from
// mozilla/browser/components/nsBrowserGlue.js
const UI_VERSION = 20;
const UI_VERSION = 21;
const MESSENGER_DOCURL = "chrome://messenger/content/messenger.xhtml";
const MESSENGERCOMPOSE_DOCURL =
"chrome://messenger/content/messengercompose/messengercompose.xhtml";
@ -500,6 +500,13 @@ var MailMigrator = {
}
}
// Make "bad" msgcompose.font_face value "tt" be "monospace" instead.
if (currentUIVersion < 21) {
if (Services.prefs.getStringPref("msgcompose.font_face") == "tt") {
Services.prefs.setStringPref("msgcompose.font_face", "monospace");
}
}
// Update the migration version.
Services.prefs.setIntPref(UI_VERSION_PREF, UI_VERSION);
} catch (e) {

Просмотреть файл

@ -427,10 +427,6 @@ function pokeMultiStateUI(uiID, cmdParams) {
let commandNode = document.getElementById(uiID);
let uiState = commandNode.getAttribute("state");
if (uiID == "cmd_fontFace" && uiState == "tt_initial") {
desiredAttrib = "tt";
goDoCommandParams(uiID, desiredAttrib);
}
if (desiredAttrib != uiState) {
commandNode.setAttribute("state", desiredAttrib);
switch (uiID) {
@ -483,7 +479,7 @@ function doStatefulCommand(commandID, newState, updateUI) {
top.document
.querySelector("editor")
.contentDocument.execCommand(command, false, null);
} else if (commandID == "cmd_fontFace" && newState == "tt") {
} else if (commandID == "cmd_fontFace" && newState == "") {
goDoCommandParams(commandID, newState);
} else {
top.document

Просмотреть файл

@ -8165,17 +8165,6 @@ function toggleAddressPicker(aFocus = true) {
function loadHTMLMsgPrefs() {
let fontFace = Services.prefs.getStringPref("msgcompose.font_face", "");
if (fontFace) {
// editor controller is not defined when execution reaches here so goDoCommandParams()
// will not do anything. "tt" requires a special case handling as it is not
// executable by document.execCommand(). So when user has set "Fixed width" as a
// default font to start with, we will call goDoCommandParams() when user first focuses
// the editor part. So when user focuses the editor part, the flow will be:
// goUpdateComposerMenuItems() > goUpdateCommandState() > pokeMultiStateUI() >
// Detect the "tt_initial" state and change it to "tt" on command node >
// goDoCommandParams().
if (fontFace == "tt") {
fontFace = "tt_initial";
}
doStatefulCommand("cmd_fontFace", fontFace, true);
}

Просмотреть файл

@ -38,7 +38,7 @@
observes="cmd_renderedHTMLEnabler">
<menupopup id="FontFacePopup">
<menuitem id="toolbarmenu_fontVarWidth" label="&fontVarWidth.label;" value=""/>
<menuitem id="toolbarmenu_fontFixedWidth" label="&fontFixedWidth.label;" value="tt"/>
<menuitem id="toolbarmenu_fontFixedWidth" label="&fontFixedWidth.label;" value="monospace"/>
<menuseparator id="toolbarmenuAfterGenericFontsSeparator"/>
<menuitem id="toolbarmenu_fontHelvetica" label="&fontHelvetica.label;"
value="Helvetica, Arial, sans-serif"

Просмотреть файл

@ -478,10 +478,6 @@ function onFontFaceChange() {
var commandNode = document.getElementById("cmd_fontFace");
var editorFont = commandNode.getAttribute("state");
if (editorFont == "tt_initial") {
editorFont = "tt";
}
// Strip quotes in font names. Experiments have shown that we only
// ever get double quotes around the font name, never single quotes,
// even if they were in the HTML source. Also single or double
@ -726,7 +722,7 @@ function initFontFaceMenu(menuPopup) {
case "tt":
case "monospace":
// Generic fixed width.
editorFont = "tt";
editorFont = "monospace";
break;
default:
editorFont = editorFont.toLowerCase().replace(/, /g, ","); // bug 1139524

Просмотреть файл

@ -1188,7 +1188,7 @@
<menuitem id="menu_fontFaceFixedWidth"
label="&fontFixedWidth.label;"
accesskey="&fontFixedWidth.accesskey;"
value="tt"
value="monospace"
type="radio"
observes="cmd_renderedHTMLEnabler"/>
<menuseparator id="fontFaceMenuAfterGenericFontsSeparator"/>

Просмотреть файл

@ -99,7 +99,7 @@
sizetopopup="pref" crop="center" flex="1">
<menupopup>
<menuitem value="" label="&fontVarWidth.label;"/>
<menuitem value="tt" label="&fontFixedWidth.label;"/>
<menuitem value="monospace" label="&fontFixedWidth.label;"/>
<menuseparator/>
<menuitem value="Helvetica, Arial, sans-serif" label="&fontHelvetica.label;"/>
<menuitem value="Times New Roman, Times, serif" label="&fontTimes.label;"/>

Просмотреть файл

@ -5037,6 +5037,14 @@ void nsMsgCompose::TagConvertible(Element* node, int32_t* _retval) {
return;
}
// Treat <font face="monospace"> as converible to plaintext.
if (element.LowerCaseEqualsLiteral("font")) {
node->GetAttribute(u"face"_ns, attribValue);
if (attribValue.LowerCaseEqualsLiteral("monospace")) {
*_retval = nsIMsgCompConvertible::Plain;
}
}
if ( // Considered convertible to plaintext: Some "simple" elements
// without non-convertible attributes like style, class, id,
// or align (see above).