Bug 1374588 - Labels aren't highlighted after performing a search r?mconley
MozReview-Commit-ID: 5S9nGqEnv6a
--- 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);