Bug 1499906 - Use non-ASCII chars directly in the code. r=erahm
☠☠ backed out by be3ea7eb7ff4 ☠ ☠
authorNicholas Nethercote <nnethercote@mozilla.com>
Thu, 18 Oct 2018 19:39:38 +1100
changeset 490360 9d2fa6237585ae36ca4922d8064944c5168883b2
parent 490359 b9614de52765a2da6de9eb067c2431c9517b95cd
child 490361 14cef5ef3dc4c9fb2e32b8b43778395ee6471c7d
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerserahm
bugs1499906
milestone64.0a1
Bug 1499906 - Use non-ASCII chars directly in the code. r=erahm They're easier to read than \uXXXX escapes, and there's no reason to stick to ASCII in the source code.
toolkit/components/aboutmemory/content/aboutMemory.js
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -320,29 +320,26 @@ function onLoad() {
   let labelDiv1 =
    appendElementWithText(row1, "div", "opsRowLabel", "Show memory reports");
   let label1 = appendElementWithText(labelDiv1, "label", "");
   gVerbose = appendElement(label1, "input", "");
   gVerbose.type = "checkbox";
   gVerbose.id = "verbose"; // used for testing
   appendTextNode(label1, "verbose");
 
-  const kEllipsis = "\u2026";
-
   // The "measureButton" id is used for testing.
   appendButton(row1, CuDesc, doMeasure, "Measure", "measureButton");
-  appendButton(row1, LdDesc, () => fileInput1.click(), "Load" + kEllipsis);
-  appendButton(row1, DfDesc, () => fileInput2.click(),
-               "Load and diff" + kEllipsis);
+  appendButton(row1, LdDesc, () => fileInput1.click(), "Load…");
+  appendButton(row1, DfDesc, () => fileInput2.click(), "Load and diff…");
 
   let row2 = appendElement(ops, "div", "opsRow");
 
   let labelDiv2 =
     appendElementWithText(row2, "div", "opsRowLabel", "Save memory reports");
-  appendButton(row2, SvDesc, saveReportsToFile, "Measure and save" + kEllipsis);
+  appendButton(row2, SvDesc, saveReportsToFile, "Measure and save…");
 
   // XXX: this isn't a great place for this checkbox, but I can't think of
   // anywhere better.
   let label2 = appendElementWithText(labelDiv2, "label", "");
   gAnonymize = appendElement(label2, "input", "");
   gAnonymize.type = "checkbox";
   appendTextNode(label2, "anonymize");
 
@@ -1414,32 +1411,29 @@ function appendWarningElements(aP, aHasK
  *        The table of degenerate trees for this process.
  * @param aHasMozMallocUsableSize
  *        Boolean indicating if moz_malloc_usable_size works.
  * @return The generated text.
  */
 function appendProcessAboutMemoryElements(aP, aN, aProcess, aTrees,
                                           aDegenerates, aHeapTotal,
                                           aHasMozMallocUsableSize) {
-  const kUpwardsArrow   = "\u2191",
-        kDownwardsArrow = "\u2193";
-
   let appendLink = function(aHere, aThere, aArrow) {
     let link = appendElementWithText(aP, "a", "upDownArrow", aArrow);
     link.href = "#" + aThere + aN;
     link.id = aHere + aN;
     link.title = "Go to the " + aThere + " of " + aProcess;
     link.style = "text-decoration: none";
 
     // This gives nice spacing when we copy and paste.
     appendElementWithText(aP, "span", "", "\n");
   };
 
   appendElementWithText(aP, "h1", "", aProcess);
-  appendLink("start", "end", kDownwardsArrow);
+  appendLink("start", "end", "↓");
 
   // We'll fill this in later.
   let warningsDiv = appendElement(aP, "div", "accuracyWarning");
 
   // The explicit tree.
   let hasExplicitTree;
   let hasKnownHeapAllocated;
   {
@@ -1509,17 +1503,17 @@ function appendProcessAboutMemoryElement
   // limitations.  These must be computed after generating all the text.  The
   // newlines give nice spacing if we copy+paste into a text buffer.
   if (hasExplicitTree) {
     appendWarningElements(warningsDiv, hasKnownHeapAllocated,
                           aHasMozMallocUsableSize);
   }
 
   appendElementWithText(aP, "h3", "", "End of " + aProcess);
-  appendLink("end", "start", kUpwardsArrow);
+  appendLink("end", "start", "↑");
 }
 
 /**
  * Determines if a number has a negative sign when converted to a string.
  * Works even for -0.
  *
  * @param aN
  *        The number.
@@ -1625,31 +1619,19 @@ function pad(aS, aN, aC) {
   let padding = "";
   let n2 = aN - aS.length;
   for (let i = 0; i < n2; i++) {
     padding += aC;
   }
   return padding + aS;
 }
 
-// There's a subset of the Unicode "light" box-drawing chars that is widely
-// implemented in terminals, and this code sticks to that subset to maximize
-// the chance that copying and pasting about:memory output to a terminal will
-// work correctly.
-const kHorizontal                   = "\u2500",
-      kVertical                     = "\u2502",
-      kUpAndRight                   = "\u2514",
-      kUpAndRight_Right_Right       = "\u2514\u2500\u2500",
-      kVerticalAndRight             = "\u251c",
-      kVerticalAndRight_Right_Right = "\u251c\u2500\u2500",
-      kVertical_Space_Space         = "\u2502  ";
-
-const kNoKidsSep                    = " \u2500\u2500 ",
-      kHideKidsSep                  = " ++ ",
-      kShowKidsSep                  = " -- ";
+const kNoKidsSep   = " ── ",
+      kHideKidsSep = " ++ ",
+      kShowKidsSep = " -- ";
 
 function appendMrNameSpan(aP, aDescription, aUnsafeName, aIsInvalid, aNMerged,
                           aPresence) {
   let safeName = flipBackslashes(aUnsafeName);
   if (!aIsInvalid && !aNMerged && !aPresence) {
     safeName += "\n";
   }
   let nameSpan = appendElementWithText(aP, "span", "mrName", safeName);
@@ -1783,17 +1765,21 @@ function expandPathToThisElement(aElemen
  *        The tree root.
  * @param aProcess
  *        The process the tree corresponds to.
  * @param aPadText
  *        A string to pad the start of each entry.
  */
 function appendTreeElements(aP, aRoot, aProcess, aPadText) {
   /**
-   * Appends the elements for a particular tree, without a heading.
+   * Appends the elements for a particular tree, without a heading. There's a
+   * subset of the Unicode "light" box-drawing chars that is widely implemented
+   * in terminals, and this code sticks to that subset to maximize the chance
+   * that copying and pasting about:memory output to a terminal will work
+   * correctly.
    *
    * @param aP
    *        The parent DOM node.
    * @param aProcess
    *        The process the tree corresponds to.
    * @param aUnsafeNames
    *        An array of the names forming the path to aT.
    * @param aRoot
@@ -1820,20 +1806,18 @@ function appendTreeElements(aP, aRoot, a
       return aS;
     }
 
     // The tree line.  Indent more if this entry is narrower than its parent.
     let valueText = aT.toString();
     let extraTreelineLength =
       Math.max(aParentStringLength - valueText.length, 0);
     if (extraTreelineLength > 0) {
-      aTreelineText2a =
-        appendN(aTreelineText2a, kHorizontal, extraTreelineLength);
-      aTreelineText2b =
-        appendN(aTreelineText2b, " ", extraTreelineLength);
+      aTreelineText2a = appendN(aTreelineText2a, "─", extraTreelineLength);
+      aTreelineText2b = appendN(aTreelineText2b, " ", extraTreelineLength);
     }
     let treelineText = aTreelineText1 + aTreelineText2a;
     appendElementWithText(aP, "span", "treeline", treelineText);
 
     // Detect and record invalid values.  But not if gIsDiff is true, because
     // we expect negative values in that case.
     assertInput(aRoot._units === aT._units,
                 "units within a tree are inconsistent");
@@ -1904,20 +1888,20 @@ function appendTreeElements(aP, aRoot, a
     if (aT._kids) {
       // The 'kids' class is just used for sanity checking in toggle().
       d = appendElement(aP, "span", showSubtrees ? "kids" : "kids hidden");
 
       let kidTreelineText1 = aTreelineText1 + aTreelineText2b;
       for (let i = 0; i < aT._kids.length; i++) {
         let kidTreelineText2a, kidTreelineText2b;
         if (i < aT._kids.length - 1) {
-          kidTreelineText2a = kVerticalAndRight_Right_Right;
-          kidTreelineText2b = kVertical_Space_Space;
+          kidTreelineText2a = "├──";
+          kidTreelineText2b = "│  ";
         } else {
-          kidTreelineText2a = kUpAndRight_Right_Right;
+          kidTreelineText2a = "└──";
           kidTreelineText2b = "   ";
         }
         aUnsafeNames.push(aT._kids[i]._unsafeName);
         appendTreeElements2(d, aProcess, aUnsafeNames, aRoot, aT._kids[i],
                             kidTreelineText1, kidTreelineText2a,
                             kidTreelineText2b, valueText.length);
         aUnsafeNames.pop();
       }