Bug 1368667 - Remove KeyValueTable as it is similar to GenericTable r=chutten
authorflyingrub <flyinggrub@gmail.com>
Thu, 01 Jun 2017 12:22:21 +0200
changeset 410187 ca9c07c8244a0d59bcbaa32ac30c139958fb243f
parent 410186 d91ee7347dce732a5ac39f488536c5d43ef92c37
child 410188 39b358a1d0ca52dd1a0292700e424853131b366f
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1368667
milestone55.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 1368667 - Remove KeyValueTable as it is similar to GenericTable r=chutten GenericTable expect an array of array as data where KeyValueTable used to expect an object. Use explodeObject() to process an object so it can be used by GenericTable. MozReview-Commit-ID: 6hxxFwF2KXg
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1439,82 +1439,16 @@ function RenderObject(aObject) {
   }
   output = "{\"" + keys[0] + "\":\u00A0" + JSON.stringify(aObject[keys[0]]);
   for (let i = 1; i < keys.length; i++) {
     output += ", \"" + keys[i] + "\":\u00A0" + JSON.stringify(aObject[keys[i]]);
   }
   return output + "}";
 }
 
-var KeyValueTable = {
-  /**
-   * Returns a 2-column table with keys and values
-   * @param aMeasurements Each key in this JS object is rendered as a row in
-   *                      the table with its corresponding value
-   * @param aKeysLabel    Column header for the keys column
-   * @param aValuesLabel  Column header for the values column
-   */
-  render: function KeyValueTable_render(aMeasurements, aKeysLabel, aValuesLabel) {
-    let table = document.createElement("table");
-    this.renderHeader(table, aKeysLabel, aValuesLabel);
-    this.renderBody(table, aMeasurements);
-    return table;
-  },
-
-  /**
-   * Create the table header
-   * Tabs & newlines added to cells to make it easier to copy-paste.
-   *
-   * @param aTable Table element
-   * @param aKeysLabel    Column header for the keys column
-   * @param aValuesLabel  Column header for the values column
-   */
-  renderHeader: function KeyValueTable_renderHeader(aTable, aKeysLabel, aValuesLabel) {
-    let headerRow = document.createElement("tr");
-    aTable.appendChild(headerRow);
-
-    let keysColumn = document.createElement("th");
-    keysColumn.appendChild(document.createTextNode(aKeysLabel + "\t"));
-    let valuesColumn = document.createElement("th");
-    valuesColumn.appendChild(document.createTextNode(aValuesLabel + "\n"));
-
-    headerRow.appendChild(keysColumn);
-    headerRow.appendChild(valuesColumn);
-  },
-
-  /**
-   * Create the table body
-   * Tabs & newlines added to cells to make it easier to copy-paste.
-   *
-   * @param aTable Table element
-   * @param aMeasurements Key/value map
-   */
-  renderBody: function KeyValueTable_renderBody(aTable, aMeasurements) {
-    for (let [key, value] of Object.entries(aMeasurements)) {
-      // use .valueOf() to unbox Number, String, etc. objects
-      if (value &&
-         (typeof value == "object") &&
-         (typeof value.valueOf() == "object")) {
-        value = RenderObject(value);
-      }
-
-      let newRow = document.createElement("tr");
-      aTable.appendChild(newRow);
-
-      let keyField = document.createElement("td");
-      keyField.appendChild(document.createTextNode(key + "\t"));
-      newRow.appendChild(keyField);
-
-      let valueField = document.createElement("td");
-      valueField.appendChild(document.createTextNode(value + "\n"));
-      newRow.appendChild(valueField);
-    }
-  }
-};
-
 var GenericTable = {
 
   defaultHeadings: [
     bundle.GetStringFromName("keysHeader"),
     bundle.GetStringFromName("valuesHeader")
   ],
 
   /**