Bug 642502 - skip fields with 0/empty/null values - r=jrmuizel
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 03 May 2011 16:07:17 -0400
changeset 68914 ae3c9370cc57f21ad218e41a16d68ad365d489e3
parent 68913 221e1a3438732e3a205382827180069064111917
child 68915 14351a8521c3874e1760b24a937880001f1c844a
push id19799
push userbjacob@mozilla.com
push dateTue, 03 May 2011 20:08:41 +0000
treeherdermozilla-central@3f208499e8b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs642502
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 642502 - skip fields with 0/empty/null values - r=jrmuizel
toolkit/content/aboutSupport.js
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -161,57 +161,51 @@ function populatePreferencesSection() {
 function populateGraphicsSection() {
   function createHeader(name)
   {
     let elem = createElement("th", name);
     elem.className = "column";
     return elem;
   }
 
+  function pushInfoRow(table, name, value)
+  {
+    if(value) {
+      table.push(createParentElement("tr", [
+        createHeader(bundle.GetStringFromName(name)),
+        createElement("td", value),
+      ]));
+    }
+  }
+
+  function hexValueToString(value)
+  {
+    return value
+           ? String('0000' + value.toString(16)).slice(-4)
+           : null;
+  }
+
   let bundle = Services.strings.createBundle("chrome://global/locale/aboutSupport.properties");
   let graphics_tbody = document.getElementById("graphics-tbody");
 
   var gfxInfo = null;
   try {
     // nsIGfxInfo is currently only implemented on Windows
     gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
   } catch(e) {}
 
   if (gfxInfo) {
     let trGraphics = [];
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("adapterDescription")),
-      createElement("td", gfxInfo.adapterDescription),
-    ]));
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("adapterVendorID")),
-      // pad with zeros. (printf would be nicer)
-      createElement("td", String('0000'+gfxInfo.adapterVendorID.toString(16)).slice(-4)),
-    ]));
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("adapterDeviceID")),
-      // pad with zeros. (printf would be nicer)
-      createElement("td", String('0000'+gfxInfo.adapterDeviceID.toString(16)).slice(-4)),
-    ]));
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("adapterRAM")),
-      createElement("td", gfxInfo.adapterRAM),
-    ]));
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("adapterDrivers")),
-      createElement("td", gfxInfo.adapterDriver),
-    ]));
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("driverVersion")),
-      createElement("td", gfxInfo.adapterDriverVersion),
-    ]));
-    trGraphics.push(createParentElement("tr", [
-      createHeader(bundle.GetStringFromName("driverDate")),
-      createElement("td", gfxInfo.adapterDriverDate),
-    ]));
+    pushInfoRow(trGraphics, "adapterDescription", gfxInfo.adapterDescription);
+    pushInfoRow(trGraphics, "adapterVendorID", hexValueToString(gfxInfo.adapterVendorID));
+    pushInfoRow(trGraphics, "adapterDeviceID", hexValueToString(gfxInfo.adapterDeviceID));
+    pushInfoRow(trGraphics, "adapterRAM", gfxInfo.adapterRAM);
+    pushInfoRow(trGraphics, "adapterDrivers", gfxInfo.adapterDriver);
+    pushInfoRow(trGraphics, "driverVersion", gfxInfo.adapterDriverVersion);
+    pushInfoRow(trGraphics, "driverDate", gfxInfo.adapterDriverDate);
 
     var d2dEnabled = false;
     try {
       d2dEnabled = gfxInfo.D2DEnabled;
     } catch(e) {}
     var d2dMessage = d2dEnabled;
     if (!d2dEnabled) {
       var d2dStatus = -1; // different from any status value defined in the IDL