| Index: Source/devtools/front_end/profiler/CPUProfileDataGrid.js
|
| diff --git a/Source/devtools/front_end/profiler/CPUProfileDataGrid.js b/Source/devtools/front_end/profiler/CPUProfileDataGrid.js
|
| index 869bd6f480bd7c96187c64b9ce91ed76cb558cc7..e2d8676bdc8b2a4363214b371f3cbee5b3665377 100644
|
| --- a/Source/devtools/front_end/profiler/CPUProfileDataGrid.js
|
| +++ b/Source/devtools/front_end/profiler/CPUProfileDataGrid.js
|
| @@ -363,6 +363,7 @@ WebInspector.ProfileDataGridNode.populate = function(container)
|
|
|
| /**
|
| * @constructor
|
| + * @implements {WebInspector.CPUProfileView.Searchable}
|
| * @param {!WebInspector.CPUProfileView} profileView
|
| * @param {!ProfilerAgent.CPUProfileNode} rootProfileNode
|
| */
|
| @@ -436,6 +437,163 @@ WebInspector.ProfileDataGridTree.prototype = {
|
| children[index].restore();
|
|
|
| this._savedChildren = null;
|
| + },
|
| +
|
| + /**
|
| + * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
|
| + * @param {boolean} shouldJump
|
| + * @param {boolean=} jumpBackwards
|
| + * @return {number}
|
| + */
|
| + performSearch: function(searchConfig, shouldJump, jumpBackwards)
|
| + {
|
| + this.searchCanceled();
|
| + var query = searchConfig.query.trim();
|
| + if (!query.length)
|
| + return 0;
|
| +
|
| + var greaterThan = (query.startsWith(">"));
|
| + var lessThan = (query.startsWith("<"));
|
| + var equalTo = (query.startsWith("=") || ((greaterThan || lessThan) && query.indexOf("=") === 1));
|
| + var percentUnits = (query.endsWith("%"));
|
| + var millisecondsUnits = (query.length > 2 && query.endsWith("ms"));
|
| + var secondsUnits = (!millisecondsUnits && query.endsWith("s"));
|
| +
|
| + var queryNumber = parseFloat(query);
|
| + if (greaterThan || lessThan || equalTo) {
|
| + if (equalTo && (greaterThan || lessThan))
|
| + queryNumber = parseFloat(query.substring(2));
|
| + else
|
| + queryNumber = parseFloat(query.substring(1));
|
| + }
|
| +
|
| + var queryNumberMilliseconds = (secondsUnits ? (queryNumber * 1000) : queryNumber);
|
| +
|
| + // Make equalTo implicitly true if it wasn't specified there is no other operator.
|
| + if (!isNaN(queryNumber) && !(greaterThan || lessThan))
|
| + equalTo = true;
|
| +
|
| + var matcher = createPlainTextSearchRegex(query, "i");
|
| +
|
| + function matchesQuery(/*ProfileDataGridNode*/ profileDataGridNode)
|
| + {
|
| + delete profileDataGridNode._searchMatchedSelfColumn;
|
| + delete profileDataGridNode._searchMatchedTotalColumn;
|
| + delete profileDataGridNode._searchMatchedFunctionColumn;
|
| +
|
| + if (percentUnits) {
|
| + if (lessThan) {
|
| + if (profileDataGridNode.selfPercent < queryNumber)
|
| + profileDataGridNode._searchMatchedSelfColumn = true;
|
| + if (profileDataGridNode.totalPercent < queryNumber)
|
| + profileDataGridNode._searchMatchedTotalColumn = true;
|
| + } else if (greaterThan) {
|
| + if (profileDataGridNode.selfPercent > queryNumber)
|
| + profileDataGridNode._searchMatchedSelfColumn = true;
|
| + if (profileDataGridNode.totalPercent > queryNumber)
|
| + profileDataGridNode._searchMatchedTotalColumn = true;
|
| + }
|
| +
|
| + if (equalTo) {
|
| + if (profileDataGridNode.selfPercent == queryNumber)
|
| + profileDataGridNode._searchMatchedSelfColumn = true;
|
| + if (profileDataGridNode.totalPercent == queryNumber)
|
| + profileDataGridNode._searchMatchedTotalColumn = true;
|
| + }
|
| + } else if (millisecondsUnits || secondsUnits) {
|
| + if (lessThan) {
|
| + if (profileDataGridNode.selfTime < queryNumberMilliseconds)
|
| + profileDataGridNode._searchMatchedSelfColumn = true;
|
| + if (profileDataGridNode.totalTime < queryNumberMilliseconds)
|
| + profileDataGridNode._searchMatchedTotalColumn = true;
|
| + } else if (greaterThan) {
|
| + if (profileDataGridNode.selfTime > queryNumberMilliseconds)
|
| + profileDataGridNode._searchMatchedSelfColumn = true;
|
| + if (profileDataGridNode.totalTime > queryNumberMilliseconds)
|
| + profileDataGridNode._searchMatchedTotalColumn = true;
|
| + }
|
| +
|
| + if (equalTo) {
|
| + if (profileDataGridNode.selfTime == queryNumberMilliseconds)
|
| + profileDataGridNode._searchMatchedSelfColumn = true;
|
| + if (profileDataGridNode.totalTime == queryNumberMilliseconds)
|
| + profileDataGridNode._searchMatchedTotalColumn = true;
|
| + }
|
| + }
|
| +
|
| + if (profileDataGridNode.functionName.match(matcher) || (profileDataGridNode.url && profileDataGridNode.url.match(matcher)))
|
| + profileDataGridNode._searchMatchedFunctionColumn = true;
|
| +
|
| + if (profileDataGridNode._searchMatchedSelfColumn ||
|
| + profileDataGridNode._searchMatchedTotalColumn ||
|
| + profileDataGridNode._searchMatchedFunctionColumn) {
|
| + profileDataGridNode.refresh();
|
| + return true;
|
| + }
|
| +
|
| + return false;
|
| + }
|
| +
|
| + var current = this.children[0];
|
| + this._searchResults = [];
|
| + while (current) {
|
| + if (matchesQuery(current))
|
| + this._searchResults.push({ profileNode: current });
|
| +
|
| + current = current.traverseNextNode(false, null, false);
|
| + }
|
| + this._searchResultIndex = jumpBackwards ? 0 : this._searchResults.length - 1;
|
| + return this._searchResults.length;
|
| + },
|
| +
|
| + searchCanceled: function()
|
| + {
|
| + if (this._searchResults) {
|
| + for (var i = 0; i < this._searchResults.length; ++i) {
|
| + var profileNode = this._searchResults[i].profileNode;
|
| + delete profileNode._searchMatchedSelfColumn;
|
| + delete profileNode._searchMatchedTotalColumn;
|
| + delete profileNode._searchMatchedFunctionColumn;
|
| + profileNode.refresh();
|
| + }
|
| + }
|
| +
|
| + this._searchResults = [];
|
| + this._searchResultIndex = -1;
|
| + },
|
| +
|
| + jumpToNextSearchResult: function()
|
| + {
|
| + if (!this._searchResults || !this._searchResults.length)
|
| + return;
|
| + this._searchResultIndex = (this._searchResultIndex + 1) % this._searchResults.length;
|
| + this._jumpToSearchResult(this._searchResultIndex);
|
| + },
|
| +
|
| + jumpToPreviousSearchResult: function()
|
| + {
|
| + if (!this._searchResults || !this._searchResults.length)
|
| + return;
|
| + this._searchResultIndex = (this._searchResultIndex - 1 + this._searchResults.length) % this._searchResults.length;
|
| + this._jumpToSearchResult(this._searchResultIndex);
|
| + },
|
| +
|
| + /**
|
| + * @return {number}
|
| + */
|
| + currentSearchResultIndex: function()
|
| + {
|
| + return this._searchResultIndex;
|
| + },
|
| +
|
| + _jumpToSearchResult: function(index)
|
| + {
|
| + var searchResult = this._searchResults[index];
|
| + if (!searchResult)
|
| + return;
|
| +
|
| + var profileNode = searchResult.profileNode;
|
| + profileNode.revealAndSelect();
|
| }
|
| }
|
|
|
|
|