Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('settings', function() { | 5 cr.define('settings', function() { |
| 6 /** @const {string} */ | 6 /** @const {string} */ |
| 7 var WRAPPER_CSS_CLASS = 'search-highlight-wrapper'; | 7 var WRAPPER_CSS_CLASS = 'search-highlight-wrapper'; |
| 8 | 8 |
| 9 /** @const {string} */ | 9 /** @const {string} */ |
| 10 var ORIGINAL_CONTENT_CSS_CLASS = 'search-highlight-original-content'; | 10 var ORIGINAL_CONTENT_CSS_CLASS = 'search-highlight-original-content'; |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 } | 142 } |
| 143 | 143 |
| 144 if (node.nodeType == Node.TEXT_NODE) { | 144 if (node.nodeType == Node.TEXT_NODE) { |
| 145 var textContent = node.nodeValue.trim(); | 145 var textContent = node.nodeValue.trim(); |
| 146 if (textContent.length == 0) | 146 if (textContent.length == 0) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 if (request.regExp.test(textContent)) { | 149 if (request.regExp.test(textContent)) { |
| 150 foundMatches = true; | 150 foundMatches = true; |
| 151 revealParentSection_(node, request.rawQuery_); | 151 revealParentSection_(node, request.rawQuery_); |
| 152 highlight_(node, textContent.split(request.regExp)); | 152 |
| 153 // Don't highlight <select> nodes (yellow rectangles can't be | |
| 154 // displayed. Just revealing the section is sufficient. | |
|
dpapad
2016/10/27 01:24:48
Highlighting <select> elements with a search bubbl
| |
| 155 if (node.parentNode.nodeName != 'OPTION') | |
| 156 highlight_(node, textContent.split(request.regExp)); | |
| 153 } | 157 } |
| 154 // Returning early since TEXT_NODE nodes never have children. | 158 // Returning early since TEXT_NODE nodes never have children. |
| 155 return; | 159 return; |
| 156 } | 160 } |
| 157 | 161 |
| 158 var child = node.firstChild; | 162 var child = node.firstChild; |
| 159 while (child !== null) { | 163 while (child !== null) { |
| 160 // Getting a reference to the |nextSibling| before calling doSearch() | 164 // Getting a reference to the |nextSibling| before calling doSearch() |
| 161 // because |child| could be removed from the DOM within doSearch(). | 165 // because |child| could be removed from the DOM within doSearch(). |
| 162 var nextSibling = child.nextSibling; | 166 var nextSibling = child.nextSibling; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 function setSearchManagerForTesting(searchManager) { | 604 function setSearchManagerForTesting(searchManager) { |
| 601 SearchManagerImpl.instance_ = searchManager; | 605 SearchManagerImpl.instance_ = searchManager; |
| 602 } | 606 } |
| 603 | 607 |
| 604 return { | 608 return { |
| 605 getSearchManager: getSearchManager, | 609 getSearchManager: getSearchManager, |
| 606 setSearchManagerForTesting: setSearchManagerForTesting, | 610 setSearchManagerForTesting: setSearchManagerForTesting, |
| 607 SearchRequest: SearchRequest, | 611 SearchRequest: SearchRequest, |
| 608 }; | 612 }; |
| 609 }); | 613 }); |
| OLD | NEW |