Bug 684323 - In about:memory, set text-overflow: ellipsis when in non-verbose mode, and set max-width: 100% when in verbose mode. r=njn
authorJustin Lebar <justin.lebar@gmail.com>
Wed, 07 Sep 2011 20:14:47 -0400
changeset 76700 aa0168e8e389d4860ce9e83fc63dc8cc6d32fe84
parent 76699 240cfe9e5c2c2438bad144cb499359e60161ebfd
child 76701 a42890e88780f1fb27a094b8d4e561983e45f8df
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersnjn
bugs684323
milestone9.0a1
Bug 684323 - In about:memory, set text-overflow: ellipsis when in non-verbose mode, and set max-width: 100% when in verbose mode. r=njn
toolkit/components/aboutmemory/content/aboutMemory.css
toolkit/components/aboutmemory/content/aboutMemory.js
toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul
--- a/toolkit/components/aboutmemory/content/aboutMemory.css
+++ b/toolkit/components/aboutmemory/content/aboutMemory.css
@@ -64,20 +64,27 @@
   -moz-user-select: none;  /* no need to include this when cutting+pasting */
 }
 
 .legend {
   font-size: 80%;
   -moz-user-select: none;  /* no need to include this when cutting+pasting */
 }
 
+body.verbose {
+  /* override setting in about.css */
+  max-width: 100% !important;
+}
+
 h2.tree {
   cursor: pointer;
   background: #ddd;
   padding-left: .1em;
 }
 
-pre.tree {
+body.non-verbose pre.tree {
+  overflow-x: hidden;
+  text-overflow: ellipsis;
 }
 
 pre.collapsed {
   display: none;
 }
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -282,16 +282,21 @@ function getReportersByProcess()
 function update()
 {
   // First, clear the page contents.  Necessary because update() might be
   // called more than once due to ChildMemoryListener.
   var content = $("content");
   content.parentNode.replaceChild(content.cloneNode(false), content);
   content = $("content");
 
+  if (gVerbose)
+    content.parentNode.classList.add('verbose');
+  else
+    content.parentNode.classList.add('non-verbose');
+
   // Generate output for one process at a time.  Always start with the
   // Main process.
   var reportersByProcess = getReportersByProcess();
   var text = genProcessText("Main", reportersByProcess["Main"]);
   for (var process in reportersByProcess) {
     if (process !== "Main") {
       text += genProcessText(process, reportersByProcess[process]);
     }
@@ -799,27 +804,19 @@ function escapeAll(aStr)
 // Compartment reporter names are URLs and so can include forward slashes.  But
 // forward slash is the memory reporter path separator.  So the memory
 // reporters change them to backslashes.  Undo that here.  
 function flipBackslashes(aStr)
 {
   return aStr.replace(/\\/g, '/');
 }
 
-// Truncate the URL in a compartment name if not in verbose mode.
-function truncateCompartmentName(aStr)
-{
-  return (gVerbose)
-       ? aStr
-       : aStr.replace(/compartment\((.{40}).*\)/, 'compartment($1...)');
-}
-
 function prepName(aStr)
 {
-  return escapeAll(flipBackslashes(truncateCompartmentName(aStr)));
+  return escapeAll(flipBackslashes(aStr));
 }
 
 function prepDesc(aStr)
 {
   return escapeQuotes(flipBackslashes(aStr));
 }
 
 function genMrNameText(aKind, aDesc, aName, aHasProblem, aNMerged)
--- a/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul
+++ b/toolkit/components/aboutmemory/tests/chrome/test_aboutmemory.xul
@@ -139,17 +139,17 @@
   var fakeReporters2 = [
     f("2nd", "heap-allocated",  OTHER,  1000 * MB),
     f("2nd", "heap-unallocated",OTHER,   100 * MB),
     f("2nd", "explicit/a/b/c",  HEAP,    497 * MB),
     f("2nd", "explicit/a/b/c",  HEAP,      1 * MB), // dup: merge
     f("2nd", "explicit/a/b/c",  HEAP,      1 * MB), // dup: merge
     f("2nd", "explicit/flip\\the\\backslashes",
                                 HEAP,    200 * MB),
-    f("2nd", "explicit/compartment(this-will-be-truncated-in-non-verbose-mode-abcdefghijklmnopqrstuvwxyz)",
+    f("2nd", "explicit/compartment(compartment-url)",
                                 HEAP,    200 * MB),
     // The escaping of compartment names must prevent this script from running.
     f("2nd", "danger<script>window.alert(1)</script>",
                                 OTHER,   666 * MB),
     f("2nd", "other1",          OTHER,   111 * MB),
 
     // kUnknown should be handled gracefully for "heap-allocated", non-leaf
     // reporters, leaf-reporters, "other" reporters, and duplicated reporters.
@@ -230,17 +230,17 @@ 222.00 MB -- other2\n\
 2nd Process\n\
 \n\
 Explicit Allocations\n\
 1,000.00 MB (100.0%) -- explicit\n\
 ├────499.00 MB (49.90%) -- a\n\
 │    └──499.00 MB (49.90%) -- b\n\
 │       └──499.00 MB (49.90%) -- c [3]\n\
 ├────200.00 MB (20.00%) -- flip/the/backslashes\n\
-├────200.00 MB (20.00%) -- compartment(this-will-be-truncated-in-non-verbose-mo...)\n\
+├────200.00 MB (20.00%) -- compartment(compartment-url)\n\
 └────101.00 MB (10.10%) -- heap-unclassified\n\
 \n\
 Resident Set Size (RSS) Breakdown\n\
 0.00 MB (100.0%) -- resident\n\
 \n\
 Virtual Size Breakdown\n\
 0.00 MB (100.0%) -- vsize\n\
 \n\
@@ -334,17 +334,17 @@ 232,783,872 B -- other2\n\
 2nd Process\n\
 \n\
 Explicit Allocations\n\
 1,048,576,000 B (100.0%) -- explicit\n\
 ├────523,239,424 B (49.90%) -- a\n\
 │    └──523,239,424 B (49.90%) -- b\n\
 │       └──523,239,424 B (49.90%) -- c [3]\n\
 ├────209,715,200 B (20.00%) -- flip/the/backslashes\n\
-├────209,715,200 B (20.00%) -- compartment(this-will-be-truncated-in-non-verbose-mode-abcdefghijklmnopqrstuvwxyz)\n\
+├────209,715,200 B (20.00%) -- compartment(compartment-url)\n\
 └────105,906,176 B (10.10%) -- heap-unclassified\n\
 \n\
 Resident Set Size (RSS) Breakdown\n\
 0 B (100.0%) -- resident\n\
 \n\
 Virtual Size Breakdown\n\
 0 B (100.0%) -- vsize\n\
 \n\