| 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 HIT_CSS_CLASS = 'search-highlight-hit'; | 10 var HIT_CSS_CLASS = 'search-highlight-hit'; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // Use existing node as placeholder to determine where to insert the | 95 // Use existing node as placeholder to determine where to insert the |
| 96 // replacement content. | 96 // replacement content. |
| 97 node.parentNode.replaceChild(wrapper, node); | 97 node.parentNode.replaceChild(wrapper, node); |
| 98 | 98 |
| 99 for (var i = 0; i < tokens.length; ++i) { | 99 for (var i = 0; i < tokens.length; ++i) { |
| 100 if (i % 2 == 0) { | 100 if (i % 2 == 0) { |
| 101 wrapper.appendChild(document.createTextNode(tokens[i])); | 101 wrapper.appendChild(document.createTextNode(tokens[i])); |
| 102 } else { | 102 } else { |
| 103 var span = document.createElement('span'); | 103 var span = document.createElement('span'); |
| 104 span.classList.add(HIT_CSS_CLASS); | 104 span.classList.add(HIT_CSS_CLASS); |
| 105 span.style.backgroundColor = '#ffeb3b'; // --var(--paper-yellow-500) |
| 105 span.textContent = tokens[i]; | 106 span.textContent = tokens[i]; |
| 106 wrapper.appendChild(span); | 107 wrapper.appendChild(span); |
| 107 } | 108 } |
| 108 } | 109 } |
| 109 } | 110 } |
| 110 | 111 |
| 111 /** | 112 /** |
| 112 * Traverses the entire DOM (including Shadow DOM), finds text nodes that | 113 * Traverses the entire DOM (including Shadow DOM), finds text nodes that |
| 113 * match the given regular expression and applies the highlight UI. It also | 114 * match the given regular expression and applies the highlight UI. It also |
| 114 * ensures that <settings-section> instances become visible if any matches | 115 * ensures that <settings-section> instances become visible if any matches |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 function setSearchManagerForTesting(searchManager) { | 577 function setSearchManagerForTesting(searchManager) { |
| 577 SearchManagerImpl.instance_ = searchManager; | 578 SearchManagerImpl.instance_ = searchManager; |
| 578 } | 579 } |
| 579 | 580 |
| 580 return { | 581 return { |
| 581 getSearchManager: getSearchManager, | 582 getSearchManager: getSearchManager, |
| 582 setSearchManagerForTesting: setSearchManagerForTesting, | 583 setSearchManagerForTesting: setSearchManagerForTesting, |
| 583 SearchRequest: SearchRequest, | 584 SearchRequest: SearchRequest, |
| 584 }; | 585 }; |
| 585 }); | 586 }); |
| OLD | NEW |