Bug 1267069 - Strip quotes in font names. r=aceman,IanN a=rkent THUNDERBIRD451b1_2016042214_RELBRANCH
authorJorg K
Sun, 24 Apr 2016 20:49:16 +0200
branchTHUNDERBIRD451b1_2016042214_RELBRANCH
changeset 27008 1391b4dd016b95942f5d7d8931ea0da28a2ecdd7
parent 27007 4ecaf16b37d1f0ff414c907c36d6306ca0b64e70
child 27009 70aee00021784132d2376086c27626a447f1ce24
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, IanN, rkent
bugs1267069
Bug 1267069 - Strip quotes in font names. r=aceman,IanN a=rkent
editor/ui/composer/content/editor.js
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -683,16 +683,22 @@ function onParagraphFormatChange(paraMen
  * @param commandID         The commandID which holds the current font name
  *                          in its "state" attribute.
  */
 function onFontFaceChange(fontFaceMenuList, commandID)
 {
   var commandNode = document.getElementById(commandID);
   var editorFont = commandNode.getAttribute("state");
 
+  // 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
+  // quotes within the font name are never returned.
+  editorFont = editorFont.replace(/"/g, "");
+
   switch (editorFont) {
   case "mixed":
     // Selection is the "mixed" ( > 1 style) state.
     fontFaceMenuList.selectedItem = null;
     fontFaceMenuList.setAttribute("label",GetString('Mixed'));
     return;
   case "":
   case "serif":
@@ -733,17 +739,17 @@ function onFontFaceChange(fontFaceMenuLi
   // 6: Separator, "menuseparator.fontFaceMenuAfterDefaultFonts"
   // from 7: Used Font Section (for quick selection)
   // followed by separator, "menuseparator.fontFaceMenuAfterUsedFonts"
   // followed by all other available fonts.
   // The following variable keeps track of where we are when we loop over the menu.
   let afterUsedFontSection = false;
 
   // The menu items not only have "label" and "value", but also some other attributes:
-  // "value_parsed": Is the toLowerCase() and space stripped value.
+  // "value_parsed": Is the toLowerCase() and space-stripped value.
   // "value_cache":  Is a concatenation of all editor fonts that were ever mapped
   //                 onto this menu item. This is done for optimization.
   // "used":         This item is in the used font section.
 
   for (let i = 0; i < menuItems.length; i++)
   {
     let menuItem = menuItems.item(i);
     if (menuItem.hasAttribute("label") && menuItem.hasAttribute("value_parsed"))
@@ -950,16 +956,23 @@ function initFontFaceMenu(menuPopup)
 
   if (menuPopup)
   {
     var children = menuPopup.childNodes;
     if (!children) return;
 
     var mixed = { value: false };
     var editorFont = GetCurrentEditor().getFontFaceState(mixed);
+
+    // 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
+    // quotes within the font name are never returned.
+    editorFont = editorFont.replace(/"/g, "");
+
     if (!mixed.value)
     {
       switch (editorFont)
       {
       case "":
       case "serif":
       case "sans-serif":
         // Generic variable width.