Bug 1374588 - Labels aren't highlighted after performing a search r=mconley
authorRicky Chien <ricky060709@gmail.com>
Fri, 23 Jun 2017 13:37:57 +0800
changeset 366096 743a610d7281ab7564634df0ecdf24c0a6043eb6
parent 366095 5c41d4abf2841e4dd3985d08025c59038d96fb2b
child 366097 4961b6529b1a7e30daba766b3dc96614322fedfe
push id45493
push userrchien@mozilla.com
push dateTue, 27 Jun 2017 00:46:19 +0000
treeherderautoland@743a610d7281 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1374588
milestone56.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 1374588 - Labels aren't highlighted after performing a search r=mconley MozReview-Commit-ID: 5S9nGqEnv6a
browser/components/preferences/in-content-new/findInPage.js
--- a/browser/components/preferences/in-content-new/findInPage.js
+++ b/browser/components/preferences/in-content-new/findInPage.js
@@ -270,30 +270,37 @@ var gSearchResultsPane = {
    * @param Node nodeObject
    *    DOM Element
    * @param String searchPhrase
    * @returns boolean
    *    Returns true when found in at least one childNode, false otherwise
    */
   searchWithinNode(nodeObject, searchPhrase) {
     let matchesFound = false;
-    if (nodeObject.childElementCount == 0 || nodeObject.tagName == "menulist") {
+    if (nodeObject.childElementCount == 0 ||
+        nodeObject.tagName == "label" ||
+        nodeObject.tagName == "description" ||
+        nodeObject.tagName == "menulist") {
       let simpleTextNodes = this.textNodeDescendants(nodeObject);
 
       for (let node of simpleTextNodes) {
         let result = this.highlightMatches([node], [node.length], node.textContent.toLowerCase(), searchPhrase);
         matchesFound = matchesFound || result;
       }
 
-      // Collecting data from boxObject
+      // Collecting data from boxObject / label / description
       let nodeSizes = [];
       let allNodeText = "";
       let runningSize = 0;
       let accessKeyTextNodes = this.textNodeDescendants(nodeObject.boxObject);
 
+      if (nodeObject.tagName == "label" || nodeObject.tagName == "description") {
+        accessKeyTextNodes.push(...this.textNodeDescendants(nodeObject));
+      }
+
       for (let node of accessKeyTextNodes) {
         runningSize += node.textContent.length;
         allNodeText += node.textContent;
         nodeSizes.push(runningSize);
       }
 
       // Access key are presented
       let complexTextNodesResult = this.highlightMatches(accessKeyTextNodes, nodeSizes, allNodeText.toLowerCase(), searchPhrase);