Bug 1389165 - Hide caption when no data for table in about:telemetry r=chutten
authorflyingrub <flyinggrub@gmail.com>
Fri, 11 Aug 2017 11:27:12 +0200
changeset 374806 850ff7976b8df05512722aa8942ff050cc054671
parent 374805 3b5f1b11db0ebd0b914c42eff7dbf44ab47cf638
child 374807 6e599cdfa3fbe50c2ec3f2d17e3c419f5a3eea04
push id48804
push userryanvm@gmail.com
push dateTue, 15 Aug 2017 14:04:16 +0000
treeherderautoland@6e599cdfa3fb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschutten
bugs1389165
milestone57.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 1389165 - Hide caption when no data for table in about:telemetry r=chutten MozReview-Commit-ID: 7wO2VisFyzI
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1413,22 +1413,27 @@ var Search = {
         };
       }
     }
     return [isPassFunc, filter]
   },
 
   filterElements(elements, filterText) {
     let [isPassFunc, filter] = this.chooseFilter(filterText);
+    let allElementHidden = true;
 
     let needLowerCase = (isPassFunc === this.isPassText);
     for (let element of elements) {
       let subject = needLowerCase ? element.id.toLowerCase() : element.id;
       element.hidden = !isPassFunc(subject, filter);
+      if (allElementHidden && !element.hidden) {
+        allElementHidden = false;
+      }
     }
+    return allElementHidden;
   },
 
   filterKeyedElements(keyedElements, filterText) {
     let [isPassFunc, filter] = this.chooseFilter(filterText);
 
     let needLowerCase = (isPassFunc === this.isPassText);
     keyedElements.forEach((keyedElement) => {
       let subject = needLowerCase ? keyedElement.key.id.toLowerCase() : keyedElement.key.id;
@@ -1486,17 +1491,20 @@ var Search = {
       for (let key of threads) {
         let datas = key.getElementsByClassName("histogram");
         keyedElements.push({key, datas});
       }
       this.filterKeyedElements(keyedElements, text);
     } else {
       let tables = selectedSection.querySelectorAll("table");
       for (let table of tables) {
-        this.filterElements(table.rows, text);
+        let allElementsHidden = this.filterElements(table.rows, text);
+        if (table.caption) {
+          table.caption.hidden = allElementsHidden;
+        }
       }
     }
   },
 }
 
 /*
  * Helper function to render JS objects with white space between top level elements
  * so that they look better in the browser