Bug 1389165 - Hide caption when no data for table in about:telemetry r?gfritzsche draft
authorflyingrub <flyinggrub@gmail.com>
Fri, 11 Aug 2017 11:27:12 +0200
changeset 644768 56bbdd0d6c4fe04a5d40818d4f1fdd4eaa4baba5
parent 644348 ba5d81c79b957b516221b2a43b50ae764c7be0d5
child 644897 4b9baa0da8b85d9f2227431f70b0f40195a45b86
child 644899 dad82928a8a42deac3f946e347a46cb128271f73
push id73544
push userbmo:flyinggrub@gmail.com
push dateFri, 11 Aug 2017 10:05:52 +0000
reviewersgfritzsche
bugs1389165
milestone57.0a1
Bug 1389165 - Hide caption when no data for table in about:telemetry r?gfritzsche MozReview-Commit-ID: 7wO2VisFyzI
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -1404,22 +1404,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;
@@ -1477,17 +1482,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