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 within an <option>. Just revealing the section is | |
| 155 // sufficient. | |
| 156 if (node.parentNode.nodeName != 'OPTION') | |
|
Dan Beam
2016/10/27 21:37:14
wait, why can't we just point an arrow at the <sel
Dan Beam
2016/10/27 21:46:09
TODO(dpapad): highlight <select> controls even if
dpapad
2016/10/27 22:14:21
Added.
| |
| 157 highlight_(node, textContent.split(request.regExp)); | |
| 153 } | 158 } |
| 154 // Returning early since TEXT_NODE nodes never have children. | 159 // Returning early since TEXT_NODE nodes never have children. |
| 155 return; | 160 return; |
| 156 } | 161 } |
| 157 | 162 |
| 158 var child = node.firstChild; | 163 var child = node.firstChild; |
| 159 while (child !== null) { | 164 while (child !== null) { |
| 160 // Getting a reference to the |nextSibling| before calling doSearch() | 165 // Getting a reference to the |nextSibling| before calling doSearch() |
| 161 // because |child| could be removed from the DOM within doSearch(). | 166 // because |child| could be removed from the DOM within doSearch(). |
| 162 var nextSibling = child.nextSibling; | 167 var nextSibling = child.nextSibling; |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 function setSearchManagerForTesting(searchManager) { | 605 function setSearchManagerForTesting(searchManager) { |
| 601 SearchManagerImpl.instance_ = searchManager; | 606 SearchManagerImpl.instance_ = searchManager; |
| 602 } | 607 } |
| 603 | 608 |
| 604 return { | 609 return { |
| 605 getSearchManager: getSearchManager, | 610 getSearchManager: getSearchManager, |
| 606 setSearchManagerForTesting: setSearchManagerForTesting, | 611 setSearchManagerForTesting: setSearchManagerForTesting, |
| 607 SearchRequest: SearchRequest, | 612 SearchRequest: SearchRequest, |
| 608 }; | 613 }; |
| 609 }); | 614 }); |
| OLD | NEW |