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

Unified Diff: chrome/browser/resources/settings/search_settings.js

Issue 2217403002: MD Settings: Tune searching algorithm to skip certain subpages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/settings/search_settings.js
diff --git a/chrome/browser/resources/settings/search_settings.js b/chrome/browser/resources/settings/search_settings.js
index bc09858f3d58500c2411a908044bf16bfc09fe65..8d657744d5d7711dcffc09b4c71950dab5eb0689 100644
--- a/chrome/browser/resources/settings/search_settings.js
+++ b/chrome/browser/resources/settings/search_settings.js
@@ -13,6 +13,12 @@ cr.define('settings', function() {
var SEARCH_BUBBLE_CSS_CLASS = 'search-bubble';
/**
+ * A CSS attribute indicating that a node shoud be ignored during searching.
+ * @const {string}
+ */
+ var SKIP_SEARCH_CSS_ATTRIBUTE = 'no-search';
+
+ /**
* List of elements types that should not be searched at all.
* The only DOM-MODULE node is in <body> which is not searched, therefore
* DOM-MODULE is not needed in this set.
@@ -116,14 +122,16 @@ cr.define('settings', function() {
var foundMatches = false;
function doSearch(node) {
if (node.nodeName == 'TEMPLATE' && node.hasAttribute('name') &&
- !node.if) {
+ !node.if && !node.hasAttribute(SKIP_SEARCH_CSS_ATTRIBUTE)) {
getSearchManager().queue_.addRenderTask(
new RenderTask(request, node));
return;
}
- if (IGNORED_ELEMENTS.has(node.nodeName))
+ if (IGNORED_ELEMENTS.has(node.nodeName) ||
+ (node.hasAttribute && node.hasAttribute(SKIP_SEARCH_CSS_ATTRIBUTE))) {
Dan Beam 2016/08/08 17:42:56 realistically, isn't every |root| an Element? if
dpapad 2016/08/08 18:15:20 hasAttribute is called on |node| not |root| here.
Dan Beam 2016/08/08 18:50:47 ah, i see, text nodes. yeah, i understand now. l
return;
+ }
if (node.nodeType == Node.TEXT_NODE) {
var textContent = node.nodeValue.trim();
@@ -199,12 +207,10 @@ cr.define('settings', function() {
parent.host : parent.parentNode;
if (parent.nodeName == 'SETTINGS-SUBPAGE') {
// TODO(dpapad): Cast to SettingsSubpageElement here.
- if (!parent.noAssociatedControl) {
- associatedControl = assert(
- parent.associatedControl,
- 'An associated control was expected for SETTINGS-SUBPAGE ' +
- parent.pageTitle + ', but was not found.');
- }
+ associatedControl = assert(
+ parent.associatedControl,
+ 'An associated control was expected for SETTINGS-SUBPAGE ' +
+ parent.pageTitle + ', but was not found.');
}
}
if (parent)

Powered by Google App Engine
This is Rietveld 408576698