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

Unified Diff: Source/devtools/front_end/profiler/CPUProfileFlameChart.js

Issue 696703003: DevTools: implement search for CPUProfiler FlameChart view (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments addressed Created 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/profiler/CPUProfileFlameChart.js
diff --git a/Source/devtools/front_end/profiler/CPUProfileFlameChart.js b/Source/devtools/front_end/profiler/CPUProfileFlameChart.js
index ecd2e02bc74d36a1b5b9ce4a4ad02a5162ad4763..29cfcc45da46a2842fca10e0f37ea46ed2c8b7ba 100644
--- a/Source/devtools/front_end/profiler/CPUProfileFlameChart.js
+++ b/Source/devtools/front_end/profiler/CPUProfileFlameChart.js
@@ -379,6 +379,7 @@ WebInspector.CPUFlameChartDataProvider.colorGenerator = function()
/**
* @constructor
+ * @implements {WebInspector.CPUProfileView.Searchable}
* @extends {WebInspector.VBox}
* @param {!WebInspector.FlameChartDataProvider} dataProvider
*/
@@ -394,6 +395,8 @@ WebInspector.CPUProfileFlameChart = function(dataProvider)
this._mainPane.show(this.element);
this._mainPane.addEventListener(WebInspector.FlameChart.Events.EntrySelected, this._onEntrySelected, this);
this._overviewPane.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged, this._onWindowChanged, this);
+ this._dataProvider = dataProvider;
+ this._searchResults = [];
}
WebInspector.CPUProfileFlameChart.prototype = {
@@ -435,6 +438,62 @@ WebInspector.CPUProfileFlameChart.prototype = {
this._mainPane.update();
},
+ /**
+ * @param {!WebInspector.SearchableView.SearchConfig} searchConfig
+ * @param {boolean} shouldJump
+ * @param {boolean=} jumpBackwards
+ * @return {number}
+ */
+ performSearch: function(searchConfig, shouldJump, jumpBackwards)
+ {
+ var matcher = createPlainTextSearchRegex(searchConfig.query, searchConfig.caseSensitive ? "": "i");
+
+ var selectedEntryIndex = this._searchResultIndex !== -1 ? this._searchResults[this._searchResultIndex] : -1;
+ this._searchResults = [];
+ var entriesCount = this._dataProvider._entryNodes.length;
+ for(var index = 0; index < entriesCount; ++index) {
+ if (this._dataProvider.entryTitle(index).match(matcher))
+ this._searchResults.push(index);
+ }
+
+ if (this._searchResults.length) {
+ this._searchResultIndex = this._searchResults.indexOf(selectedEntryIndex);
+ if (this._searchResultIndex === -1)
+ this._searchResultIndex = jumpBackwards ? this._searchResults.length - 1 : 0;
+ this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIndex]);
+ } else
+ this.searchCanceled();
+
+ return this._searchResults.length;
+ },
+
+ searchCanceled: function()
+ {
+ this._mainPane.setSelectedEntry(-1);
+ this._searchResults = [];
+ this._searchResultIndex = -1;
+ },
+
+ jumpToNextSearchResult: function()
+ {
+ this._searchResultIndex = (this._searchResultIndex + 1) % this._searchResults.length;
+ this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIndex]);
+ },
+
+ jumpToPreviousSearchResult: function()
+ {
+ this._searchResultIndex = (this._searchResultIndex - 1 + this._searchResults.length) % this._searchResults.length;
+ this._mainPane.setSelectedEntry(this._searchResults[this._searchResultIndex]);
+ },
+
+ /**
+ * @return {number}
+ */
+ currentSearchResultIndex: function()
+ {
+ return this._searchResultIndex;
+ },
+
__proto__: WebInspector.VBox.prototype
};
« no previous file with comments | « Source/devtools/front_end/profiler/CPUProfileDataGrid.js ('k') | Source/devtools/front_end/profiler/CPUProfileView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698