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

Unified Diff: Source/devtools/front_end/components/FilterSuggestionBuilder.js

Issue 654923002: Dev Tools: NetworkPanel: Allow negation of filtering (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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: Source/devtools/front_end/components/FilterSuggestionBuilder.js
diff --git a/Source/devtools/front_end/components/FilterSuggestionBuilder.js b/Source/devtools/front_end/components/FilterSuggestionBuilder.js
index 81075b461dfab5fedd27909a26e6c82f926b6faa..42dd81542802edbc377fa294089cd2e2d0b277b1 100644
--- a/Source/devtools/front_end/components/FilterSuggestionBuilder.js
+++ b/Source/devtools/front_end/components/FilterSuggestionBuilder.js
@@ -40,6 +40,9 @@ WebInspector.FilterSuggestionBuilder = function(keys)
this._valueLists = {};
}
+/** @typedef {{type: string, data: string, negative: boolean}} */
+WebInspector.FilterSuggestionBuilder.Filter;
+
WebInspector.FilterSuggestionBuilder.prototype = {
/**
* @param {!HTMLInputElement} input
@@ -60,6 +63,10 @@ WebInspector.FilterSuggestionBuilder.prototype = {
if (!prefix)
return [];
+ var negative = prefix.startsWith("-");
+ if (negative)
+ prefix = prefix.substring(1);
+ var modifier = negative ? "-" : "";
var valueDelimiterIndex = prefix.indexOf(":");
var suggestions = [];
@@ -67,7 +74,7 @@ WebInspector.FilterSuggestionBuilder.prototype = {
var matcher = new RegExp("^" + prefix.escapeForRegExp(), "i");
for (var j = 0; j < this._keys.length; ++j) {
if (this._keys[j].match(matcher))
- suggestions.push(this._keys[j] + ":");
+ suggestions.push(modifier + this._keys[j] + ":");
}
} else {
var key = prefix.substring(0, valueDelimiterIndex);
@@ -76,7 +83,7 @@ WebInspector.FilterSuggestionBuilder.prototype = {
var items = this._values(key);
for (var i = 0; i < items.length; ++i) {
if (items[i].match(matcher) && (items[i] !== value))
- suggestions.push(key + ":" + items[i]);
+ suggestions.push(modifier + key + ":" + items[i]);
}
}
return suggestions;
@@ -155,11 +162,11 @@ WebInspector.FilterSuggestionBuilder.prototype = {
/**
* @param {string} query
- * @return {{text: !Array.<string>, filters: !Object.<string, string>}}
+ * @return {{text: !Array.<string>, filters: !Array.<!WebInspector.FilterSuggestionBuilder.Filter>}}
*/
parseQuery: function(query)
{
- var filters = {};
+ var filters = [];
var text = [];
var i = 0;
var j = 0;
@@ -174,6 +181,9 @@ WebInspector.FilterSuggestionBuilder.prototype = {
}
var spaceIndex = query.lastIndexOf(" ", colonIndex);
var key = query.substring(spaceIndex + 1, colonIndex);
+ var negative = key.startsWith("-");
+ if (negative)
+ key = key.substring(1);
if (this._keys.indexOf(key) == -1) {
i = colonIndex + 1;
continue;
@@ -183,10 +193,10 @@ WebInspector.FilterSuggestionBuilder.prototype = {
text.push(part);
var nextSpace = query.indexOf(" ", colonIndex + 1);
if (nextSpace == -1) {
- filters[key] = query.substring(colonIndex + 1);
+ filters.push({type: key, data: query.substring(colonIndex + 1), negative: negative});
break;
}
- filters[key] = query.substring(colonIndex + 1, nextSpace);
+ filters.push({type: key, data: query.substring(colonIndex + 1, nextSpace), negative: negative});
i = nextSpace + 1;
j = i;
}
« no previous file with comments | « LayoutTests/inspector/network/network-filter-parser-expected.txt ('k') | Source/devtools/front_end/network/NetworkPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698