Bug 757299 (part 8) - Build percentage text in a better way in aboutMemory.js. r=jlebar.
authorNicholas Nethercote <nnethercote@mozilla.com>
Sun, 27 May 2012 18:17:05 -0700
changeset 99157 cd59583cf7d4fc9c20662181659026398c3c3818
parent 99156 1d98ab2314e0e03fb481edd682ef1d6b12e26a4b
child 99158 a9a778e471d1f9706de4bd9b149d2acfb1b91d4c
push idunknown
push userunknown
push dateunknown
reviewersjlebar
bugs757299
milestone15.0a1
Bug 757299 (part 8) - Build percentage text in a better way in aboutMemory.js. r=jlebar.
toolkit/components/aboutmemory/content/aboutMemory.js
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -1229,32 +1229,32 @@ function appendTreeElements(aPOuter, aT,
     }
     else {
       indentText = aBaseIndentText;
     }
     appendElementWithText(aP, "span", "treeLine", indentText);
 
     // Generate the percentage;  detect and record invalid values at the same
     // time.
-    let percText = "";
+    let percText;
     let tIsInvalid = false;
     if (aT._amount === treeBytes) {
-      percText = "100.0";
+      percText = " (100.0%)";
     } else {
       if (!(0 <= aT._amount && aT._amount <= treeBytes)) {
         tIsInvalid = true;
         let unsafePath = aUnsafeNames.join("/");
         gUnsafePathsWithInvalidValuesForThisProcess.push(unsafePath);
         reportAssertionFailure("Invalid value for " +
                                flipBackslashes(unsafePath));
       }
-      percText = (100 * aT._amount / treeBytes).toFixed(2);
-      percText = pad(percText, 5, '0');
+      let num = 100 * aT._amount / treeBytes;
+      let numText = num.toFixed(2);
+      percText = (0 <= num && num < 10 ? " (0" : " (") + numText + "%)";
     }
-    percText = " (" + percText + "%)";
 
     // For non-leaf nodes, the entire sub-tree is put within a span so it can
     // be collapsed if the node is clicked on.
     let d;
     let sep;
     let showSubtrees;
     if (aT._kids) {
       // Determine if we should show the sub-tree below this entry;  this