summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorallada <allada@chromium.org>2016-03-25 02:32:59 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-25 09:34:06 +0000
commit413558b12f7490a9a8a131da82f597b200b5a80d (patch)
tree4534ada545e91435b00b614b8e1929e9f8869898
parent5caf6fd59d6f35157a3e6ba4728434ac3d1b0886 (diff)
downloadchromium_src-413558b12f7490a9a8a131da82f597b200b5a80d.zip
chromium_src-413558b12f7490a9a8a131da82f597b200b5a80d.tar.gz
chromium_src-413558b12f7490a9a8a131da82f597b200b5a80d.tar.bz2
Added regex support in search for network tab
Users may now filter with regular expression (optional checkbox) in the network tab http://imgur.com/a0ZKF4f BUG=576022 R=lushnikov Review URL: https://codereview.chromium.org/1817193003 Cr-Commit-Position: refs/heads/master@{#383266}
-rw-r--r--third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js23
-rw-r--r--third_party/WebKit/Source/devtools/front_end/ui/FilterBar.js15
2 files changed, 30 insertions, 8 deletions
diff --git a/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js b/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js
index fe06f36..c960d3d 100644
--- a/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js
+++ b/third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js
@@ -252,7 +252,7 @@ WebInspector.NetworkLogView.prototype = {
_addFilters: function()
{
- this._textFilterUI = new WebInspector.TextFilterUI();
+ this._textFilterUI = new WebInspector.TextFilterUI(true);
this._textFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterChanged, this._filterChanged, this);
this._filterBar.addFilter(this._textFilterUI);
@@ -1570,7 +1570,7 @@ WebInspector.NetworkLogView.prototype = {
*/
supportsRegexSearch: function()
{
- return false;
+ return true;
},
/**
@@ -1634,8 +1634,14 @@ WebInspector.NetworkLogView.prototype = {
*/
_parseFilterQuery: function(query)
{
- var parsedQuery = this._suggestionBuilder.parseQuery(query);
- this._filters = parsedQuery.text.map(this._createTextFilter);
+ var parsedQuery;
+ if (this._textFilterUI.isRegexChecked() && query !== "")
+ parsedQuery = {text: [query], filters: []};
+ else
+ parsedQuery = this._suggestionBuilder.parseQuery(query);
+
+ this._filters = parsedQuery.text.map(this._createTextFilter, this);
+
var n = parsedQuery.filters.length;
for (var i = 0; i < n; ++i) {
var filter = parsedQuery.filters[i];
@@ -1651,11 +1657,12 @@ WebInspector.NetworkLogView.prototype = {
_createTextFilter: function(text)
{
var negative = false;
- if (text[0] === "-" && text.length > 1) {
+ if (!this._textFilterUI.isRegexChecked() && text[0] === "-" && text.length > 1) {
negative = true;
text = text.substring(1);
}
- var regexp = new RegExp(text.escapeForRegExp(), "i");
+ var regexp = this._textFilterUI.regex();
+
var filter = WebInspector.NetworkLogView._requestNameOrPathFilter.bind(null, regexp);
if (negative)
filter = WebInspector.NetworkLogView._negativeFilter.bind(null, filter);
@@ -1935,12 +1942,14 @@ WebInspector.NetworkLogView._negativeFilter = function(filter, request)
}
/**
- * @param {!RegExp} regex
+ * @param {?RegExp} regex
* @param {!WebInspector.NetworkRequest} request
* @return {boolean}
*/
WebInspector.NetworkLogView._requestNameOrPathFilter = function(regex, request)
{
+ if (!regex)
+ return false;
return regex.test(request.name()) || regex.test(request.path());
}
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/FilterBar.js b/third_party/WebKit/Source/devtools/front_end/ui/FilterBar.js
index 455cc11..3ff7518 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/FilterBar.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/FilterBar.js
@@ -265,6 +265,14 @@ WebInspector.TextFilterUI.prototype = {
},
/**
+ * @return {boolean}
+ */
+ isRegexChecked: function()
+ {
+ return this._supportRegex ? this._regexCheckBox.checked : false;
+ },
+
+ /**
* @return {string}
*/
value: function()
@@ -341,6 +349,11 @@ WebInspector.TextFilterUI.prototype = {
{
if (!this._suggestionBuilder)
return;
+ if (this.isRegexChecked()) {
+ if (this._suggestBox.visible())
+ this._suggestBox.hide();
+ return;
+ }
var suggestions = this._suggestionBuilder.buildSuggestions(this._filterInputElement);
if (suggestions && suggestions.length) {
if (this._suppressSuggestion)
@@ -369,7 +382,7 @@ WebInspector.TextFilterUI.prototype = {
this._regex = null;
this._filterInputElement.classList.remove("filter-text-invalid");
if (filterQuery) {
- if (this._supportRegex && this._regexCheckBox.checked) {
+ if (this.isRegexChecked()) {
try {
this._regex = new RegExp(filterQuery, "i");
} catch (e) {