Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(685)

Side by Side Diff: chrome/browser/resources/settings/search_settings.js

Issue 2454023002: MD Settings: Fix <select> search highlighting. (Closed)
Patch Set: Use loadScript. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/cr_settings_browsertest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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>.
155 // TODO(dpapad): highlight <select> controls with a search bubble
156 // instead.
157 if (node.parentNode.nodeName != 'OPTION')
158 highlight_(node, textContent.split(request.regExp));
153 } 159 }
154 // Returning early since TEXT_NODE nodes never have children. 160 // Returning early since TEXT_NODE nodes never have children.
155 return; 161 return;
156 } 162 }
157 163
158 var child = node.firstChild; 164 var child = node.firstChild;
159 while (child !== null) { 165 while (child !== null) {
160 // Getting a reference to the |nextSibling| before calling doSearch() 166 // Getting a reference to the |nextSibling| before calling doSearch()
161 // because |child| could be removed from the DOM within doSearch(). 167 // because |child| could be removed from the DOM within doSearch().
162 var nextSibling = child.nextSibling; 168 var nextSibling = child.nextSibling;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 function setSearchManagerForTesting(searchManager) { 606 function setSearchManagerForTesting(searchManager) {
601 SearchManagerImpl.instance_ = searchManager; 607 SearchManagerImpl.instance_ = searchManager;
602 } 608 }
603 609
604 return { 610 return {
605 getSearchManager: getSearchManager, 611 getSearchManager: getSearchManager,
606 setSearchManagerForTesting: setSearchManagerForTesting, 612 setSearchManagerForTesting: setSearchManagerForTesting,
607 SearchRequest: SearchRequest, 613 SearchRequest: SearchRequest,
608 }; 614 };
609 }); 615 });
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/webui/settings/cr_settings_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698