Bug 1390499 - Show all second level headers in Preferences search result r?jaws draft
authorRicky Chien <ricky060709@gmail.com>
Thu, 17 Aug 2017 18:31:42 +0800
changeset 648181 2375ff51dbce7f70c64497e6946e7d2b5d28dc1c
parent 648046 932388b8c22c9775264e543697ce918415db9e23
child 726738 c4ae4067fb9c37955180e1c8e1d3e165597c9b46
push id74658
push userbmo:rchien@mozilla.com
push dateThu, 17 Aug 2017 10:33:03 +0000
reviewersjaws
bugs1390499
milestone57.0a1
Bug 1390499 - Show all second level headers in Preferences search result r?jaws
browser/components/preferences/in-content-new/findInPage.js
browser/components/preferences/in-content-new/main.xul
browser/components/preferences/in-content-new/preferences.js
browser/components/preferences/in-content-new/privacy.xul
--- a/browser/components/preferences/in-content-new/findInPage.js
+++ b/browser/components/preferences/in-content-new/findInPage.js
@@ -234,16 +234,23 @@ var gSearchResultsPane = {
       gotoPref("paneSearchResults");
 
       let resultsFound = false;
 
       // Building the range for highlighted areas
       let rootPreferencesChildren = document
         .querySelectorAll("#mainPrefPane > *:not([data-hidden-from-search])");
 
+      // Show all second level headers in search result
+      for (let element of document.querySelectorAll("caption.search-header")) {
+        if (element.classList.contains("search-header")) {
+          element.hidden = false;
+        }
+      }
+
       if (subQuery) {
         // Since the previous query is a subset of the current query,
         // there is no need to check elements that is hidden already.
         rootPreferencesChildren =
           Array.prototype.filter.call(rootPreferencesChildren, el => !el.hidden);
       }
 
       // Mark all the children to check be visible to bind JS, Access Keys, etc,
@@ -313,16 +320,23 @@ var gSearchResultsPane = {
             Services.telemetry.keyedScalarAdd("preferences.search_query", this.query, 1);
           }, 1000);
         }
       }
     } else {
       document.getElementById("sorry-message").textContent = "";
       // Going back to General when cleared
       gotoPref("paneGeneral");
+
+      // Hide some special second level headers in normal view
+      for (let element of document.querySelectorAll("caption.search-header")) {
+        if (element.classList.contains("search-header")) {
+          element.hidden = true;
+        }
+      }
     }
 
     window.dispatchEvent(new CustomEvent("PreferencesSearchCompleted", { detail: query }));
   },
 
   /**
    * Finding leaf nodes and checking their content for words to search,
    * It is a recursive function
--- a/browser/components/preferences/in-content-new/main.xul
+++ b/browser/components/preferences/in-content-new/main.xul
@@ -750,16 +750,17 @@
       class="subcategory"
       hidden="true"
       data-category="paneGeneral">
   <label class="header-name" flex="1">&updateApplication.label;</label>
 </hbox>
 
 <!-- Update -->
 <groupbox id="updateApp" data-category="paneGeneral" hidden="true">
+  <caption class="search-header" hidden="true"><label>&updateApplication.label;</label></caption>
   <label>&updateApplicationDescription.label;</label>
   <hbox align="start">
     <vbox flex="1">
       <description>
         &updateApplication.version.pre;<label id="version"/>&updateApplication.version.post;
         <label id="releasenotes" class="learnMore text-link" hidden="true">&releaseNotes.link;</label>
       </description>
       <description id="distribution" class="text-blurb" hidden="true"/>
@@ -902,16 +903,17 @@
       class="subcategory"
       hidden="true"
       data-category="paneGeneral">
   <label class="header-name" flex="1">&performance.label;</label>
 </hbox>
 
 <!-- Performance -->
 <groupbox id="performanceGroup" data-category="paneGeneral" hidden="true">
+  <caption class="search-header" hidden="true"><label>&performance.label;</label></caption>
   <hbox align="center">
     <checkbox id="useRecommendedPerformanceSettings"
               label="&useRecommendedPerformanceSettings2.label;"
               accesskey="&useRecommendedPerformanceSettings2.accesskey;"
               preference="browser.preferences.defaultPerformanceSettings.enabled"/>
     <label id="performanceSettingsLearnMore" class="learnMore text-link">&performanceSettingsLearnMore.label;</label>
   </hbox>
   <description class="indent">&useRecommendedPerformanceSettings2.description;</description>
@@ -944,16 +946,17 @@
       class="subcategory"
       hidden="true"
       data-category="paneGeneral">
   <label class="header-name" flex="1">&browsing.label;</label>
 </hbox>
 
 <!-- Browsing -->
 <groupbox id="browsingGroup" data-category="paneGeneral" hidden="true">
+  <caption class="search-header" hidden="true"><label>&browsing.label;</label></caption>
   <checkbox id="useAutoScroll"
             label="&useAutoScroll.label;"
             accesskey="&useAutoScroll.accesskey;"
             preference="general.autoScroll"/>
   <checkbox id="useSmoothScrolling"
             label="&useSmoothScrolling.label;"
             accesskey="&useSmoothScrolling.accesskey;"
             preference="general.smoothScroll"/>
@@ -979,16 +982,17 @@
       class="subcategory"
       hidden="true"
       data-category="paneGeneral">
   <label class="header-name" flex="1">&networkProxy.label;</label>
 </hbox>
 
 <!-- Network Proxy-->
 <groupbox id="connectionGroup" data-category="paneGeneral" hidden="true">
+  <caption class="search-header" hidden="true"><label>&networkProxy.label;</label></caption>
   <hbox align="center">
     <description flex="1" control="connectionSettings">&connectionDesc.label;</description>
     <!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
     <hbox>
       <button id="connectionSettings"
               class="accessory-button"
               icon="network"
               label="&connectionSettings.label;"
--- a/browser/components/preferences/in-content-new/preferences.js
+++ b/browser/components/preferences/in-content-new/preferences.js
@@ -215,16 +215,17 @@ function gotoPref(aCategory) {
   Services.telemetry
           .getHistogramById("FX_PREFERENCES_CATEGORY_OPENED_V2")
           .add(telemetryBucketForCategory(friendlyName));
 }
 
 function search(aQuery, aAttribute, aSubquery, aSubAttribute) {
   let mainPrefPane = document.getElementById("mainPrefPane");
   let elements = mainPrefPane.children;
+
   for (let element of elements) {
     // If the "data-hidden-from-search" is "true", the
     // element will not get considered during search. This
     // should only be used when an element is still under
     // development and should not be shown for any reason.
     if (element.getAttribute("data-hidden-from-search") != "true" ||
         element.getAttribute("data-subpanel") == "true") {
       let attributeValue = element.getAttribute(aAttribute);
--- a/browser/components/preferences/in-content-new/privacy.xul
+++ b/browser/components/preferences/in-content-new/privacy.xul
@@ -531,16 +531,17 @@
       class="subcategory"
       hidden="true"
       data-category="panePrivacy">
   <label class="header-name" flex="1">&permissions.label;</label>
 </hbox>
 
 <!-- Permissions -->
 <groupbox id="permissionsGroup" data-category="panePrivacy" hidden="true">
+  <caption class="search-header" hidden="true"><label>&permissions.label;</label></caption>
   <grid>
     <columns>
       <column flex="1"/>
       <column/>
     </columns>
     <rows>
       <row id="locationSettingsRow" align="center">
         <description flex="1">
@@ -672,16 +673,17 @@
       data-category="panePrivacy"
       data-subcategory="reports">
   <label class="header-name" flex="1">&dataCollection.label;</label>
 </hbox>
 
 <!-- Firefox Data Collection and Use -->
 #ifdef MOZ_DATA_REPORTING
 <groupbox id="dataCollectionGroup" data-category="panePrivacy" data-subcategory="reports" hidden="true">
+  <caption class="search-header" hidden="true"><label>&dataCollection.label;</label></caption>
   <description>
     &dataCollectionDesc.label;<label id="dataCollectionPrivacyNotice" class="learnMore text-link">&dataCollectionPrivacyNotice.label;</label>
   </description>
 
   <vbox>
     <description flex="1">
       <checkbox id="submitHealthReportBox" label="&enableHealthReport1.label;"
                 accesskey="&enableHealthReport1.accesskey;"/>