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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/EventsTimelineTreeView.js

Issue 2686993002: DevTools: Turn FilterBar into Toolbar in timeline events log view. (Closed)
Patch Set: Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelineTreeView.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @unrestricted 6 * @unrestricted
7 */ 7 */
8 Timeline.EventsTimelineTreeView = class extends Timeline.TimelineTreeView { 8 Timeline.EventsTimelineTreeView = class extends Timeline.TimelineTreeView {
9 /** 9 /**
10 * @param {!TimelineModel.TimelineModel} model 10 * @param {!TimelineModel.TimelineModel} model
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (expand) 84 if (expand)
85 this.dataGridNodeForTreeNode(node).expand(); 85 this.dataGridNodeForTreeNode(node).expand();
86 } 86 }
87 87
88 /** 88 /**
89 * @override 89 * @override
90 * @param {!Array<!DataGrid.DataGrid.ColumnDescriptor>} columns 90 * @param {!Array<!DataGrid.DataGrid.ColumnDescriptor>} columns
91 */ 91 */
92 populateColumns(columns) { 92 populateColumns(columns) {
93 columns.push( 93 columns.push(
94 {id: 'startTime', title: Common.UIString('Start Time'), width: '110px', fixedWidth: true, sortable: true}); 94 {id: 'startTime', title: Common.UIString('Start Time'), width: '80px', f ixedWidth: true, sortable: true});
95 super.populateColumns(columns); 95 super.populateColumns(columns);
96 columns.filter(c => c.fixedWidth).forEach(c => c.width = '80px');
96 } 97 }
97 98
98 /** 99 /**
99 * @override 100 * @override
100 * @param {!Element} parent 101 * @param {!UI.Toolbar} toolbar
101 */ 102 */
102 _populateToolbar(parent) { 103 _populateToolbar(toolbar) {
103 var filtersWidget = this._filtersControl.filtersWidget(); 104 this._filtersControl.populateToolbar(toolbar);
104 filtersWidget.forceShowFilterBar();
105 filtersWidget.show(parent);
106 } 105 }
107 106
108 /** 107 /**
109 * @override 108 * @override
110 * @param {!TimelineModel.TimelineProfileTree.Node} node 109 * @param {!TimelineModel.TimelineProfileTree.Node} node
111 * @return {boolean} 110 * @return {boolean}
112 */ 111 */
113 _showDetailsForNode(node) { 112 _showDetailsForNode(node) {
114 var traceEvent = node.event; 113 var traceEvent = node.event;
115 if (!traceEvent) 114 if (!traceEvent)
(...skipping 19 matching lines...) Expand all
135 this._delegate.highlightEvent(node && node.event); 134 this._delegate.highlightEvent(node && node.event);
136 } 135 }
137 }; 136 };
138 137
139 /** 138 /**
140 * @unrestricted 139 * @unrestricted
141 */ 140 */
142 Timeline.EventsTimelineTreeView.Filters = class extends Common.Object { 141 Timeline.EventsTimelineTreeView.Filters = class extends Common.Object {
143 constructor() { 142 constructor() {
144 super(); 143 super();
145
146 this._categoryFilter = new Timeline.TimelineFilters.Category(); 144 this._categoryFilter = new Timeline.TimelineFilters.Category();
147 this._durationFilter = new Timeline.TimelineFilters.IsLong(); 145 this._durationFilter = new Timeline.TimelineFilters.IsLong();
148 this._textFilter = new Timeline.TimelineFilters.RegExp(); 146 this._textFilter = new Timeline.TimelineFilters.RegExp();
149 this._filters = [this._categoryFilter, this._durationFilter, this._textFilte r]; 147 this._filters = [this._categoryFilter, this._durationFilter, this._textFilte r];
150
151 this._createFilterBar();
152 } 148 }
153 149
154 /** 150 /**
155 * @return {!Array<!TimelineModel.TimelineModelFilter>} 151 * @return {!Array<!TimelineModel.TimelineModelFilter>}
156 */ 152 */
157 filters() { 153 filters() {
158 return this._filters; 154 return this._filters;
159 } 155 }
160 156
161 /** 157 /**
162 * @return {?RegExp} 158 * @param {!UI.Toolbar} toolbar
163 */ 159 */
164 searchRegExp() { 160 populateToolbar(toolbar) {
165 return this._textFilter.regExp(); 161 this._textFilterUI = new UI.ToolbarInput(Common.UIString('Filter'));
166 } 162 this._textFilterUI.addEventListener(UI.ToolbarInput.Event.TextChanged, textF ilterChanged, this);
163 toolbar.appendToolbarItem(this._textFilterUI);
167 164
168 /** 165 var durationFilterUI = new UI.ToolbarComboBox(durationFilterChanged.bind(thi s));
169 * @return {!UI.ToolbarItem}
170 */
171 filterButton() {
172 return this._filterBar.filterButton();
173 }
174
175 /**
176 * @return {!UI.Widget}
177 */
178 filtersWidget() {
179 return this._filterBar;
180 }
181
182 _createFilterBar() {
183 this._filterBar = new UI.FilterBar('timelinePanel');
184
185 this._textFilterUI = new UI.TextFilterUI();
186 this._textFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, textFi lterChanged, this);
187 this._filterBar.addFilter(this._textFilterUI);
188
189 var durationOptions = [];
190 for (var durationMs of Timeline.EventsTimelineTreeView.Filters._durationFilt erPresetsMs) { 166 for (var durationMs of Timeline.EventsTimelineTreeView.Filters._durationFilt erPresetsMs) {
191 var durationOption = {}; 167 var label, title;
caseq 2017/02/09 00:46:04 split into two lines.
192 if (!durationMs) { 168 if (!durationMs) {
193 durationOption.label = Common.UIString('All'); 169 label = Common.UIString('All');
194 durationOption.title = Common.UIString('Show all records'); 170 title = Common.UIString('Show all records');
195 } else { 171 } else {
196 durationOption.label = Common.UIString('\u2265 %dms', durationMs); 172 label = Common.UIString('\u2265 %dms', durationMs);
197 durationOption.title = Common.UIString('Hide records shorter than %dms', durationMs); 173 title = Common.UIString('Hide records shorter than %d\u2009ms', duration Ms);
198 } 174 }
199 durationOption.value = String(durationMs); 175 var value = String(durationMs);
200 durationOptions.push(durationOption); 176 durationFilterUI.addOption(durationFilterUI.createOption(label, title, val ue));
caseq 2017/02/09 00:46:04 perhaps just call create option with appropriate l
alph 2017/02/09 01:01:50 Done.
201 } 177 }
202 var durationFilterUI = new UI.ComboBoxFilterUI(durationOptions); 178 toolbar.appendToolbarItem(durationFilterUI);
203 durationFilterUI.addEventListener(UI.FilterUI.Events.FilterChanged, duration FilterChanged, this);
204 this._filterBar.addFilter(durationFilterUI);
205 179
206 var categoryFiltersUI = {}; 180 var categoryFiltersUI = {};
207 var categories = Timeline.TimelineUIUtils.categories(); 181 var categories = Timeline.TimelineUIUtils.categories();
208 for (var categoryName in categories) { 182 for (var categoryName in categories) {
209 var category = categories[categoryName]; 183 var category = categories[categoryName];
210 if (!category.visible) 184 if (!category.visible)
211 continue; 185 continue;
212 var filter = new UI.CheckboxFilterUI(category.name, category.title); 186 var checkbox = new UI.ToolbarCheckbox(
213 filter.setColor(category.color, 'rgba(0, 0, 0, 0.2)'); 187 category.title, undefined, undefined, categoriesFilterChanged.bind(thi s, categoryName));
214 categoryFiltersUI[category.name] = filter; 188 checkbox.setChecked(true);
215 filter.addEventListener(UI.FilterUI.Events.FilterChanged, categoriesFilter Changed.bind(this, categoryName)); 189 checkbox.inputElement.style.backgroundColor = category.color;
216 this._filterBar.addFilter(filter); 190 categoryFiltersUI[category.name] = checkbox;
191 toolbar.appendToolbarItem(checkbox);
217 } 192 }
218 return this._filterBar;
219 193
220 /** 194 /**
221 * @this {Timeline.EventsTimelineTreeView.Filters} 195 * @this {Timeline.EventsTimelineTreeView.Filters}
222 */ 196 */
223 function textFilterChanged() { 197 function textFilterChanged() {
224 var searchQuery = this._textFilterUI.value(); 198 var searchQuery = this._textFilterUI.value();
225 this._textFilter.setRegExp(searchQuery ? createPlainTextSearchRegex(search Query, 'i') : null); 199 this._textFilter.setRegExp(searchQuery ? createPlainTextSearchRegex(search Query, 'i') : null);
226 this._notifyFiltersChanged(); 200 this._notifyFiltersChanged();
227 } 201 }
228 202
229 /** 203 /**
230 * @this {Timeline.EventsTimelineTreeView.Filters} 204 * @this {Timeline.EventsTimelineTreeView.Filters}
231 */ 205 */
232 function durationFilterChanged() { 206 function durationFilterChanged() {
233 var duration = durationFilterUI.value(); 207 var duration = durationFilterUI.selectedOption().value;
234 var minimumRecordDuration = parseInt(duration, 10); 208 var minimumRecordDuration = parseInt(duration, 10);
235 this._durationFilter.setMinimumRecordDuration(minimumRecordDuration); 209 this._durationFilter.setMinimumRecordDuration(minimumRecordDuration);
236 this._notifyFiltersChanged(); 210 this._notifyFiltersChanged();
237 } 211 }
238 212
239 /** 213 /**
240 * @param {string} name 214 * @param {string} name
241 * @this {Timeline.EventsTimelineTreeView.Filters} 215 * @this {Timeline.EventsTimelineTreeView.Filters}
242 */ 216 */
243 function categoriesFilterChanged(name) { 217 function categoriesFilterChanged(name) {
244 var categories = Timeline.TimelineUIUtils.categories(); 218 var categories = Timeline.TimelineUIUtils.categories();
245 categories[name].hidden = !categoryFiltersUI[name].checked(); 219 categories[name].hidden = !categoryFiltersUI[name].checked();
246 this._notifyFiltersChanged(); 220 this._notifyFiltersChanged();
247 } 221 }
248 } 222 }
249 223
250 _notifyFiltersChanged() { 224 _notifyFiltersChanged() {
251 this.dispatchEventToListeners(Timeline.EventsTimelineTreeView.Filters.Events .FilterChanged); 225 this.dispatchEventToListeners(Timeline.EventsTimelineTreeView.Filters.Events .FilterChanged);
252 } 226 }
253 }; 227 };
254 228
255 Timeline.EventsTimelineTreeView.Filters._durationFilterPresetsMs = [0, 1, 15]; 229 Timeline.EventsTimelineTreeView.Filters._durationFilterPresetsMs = [0, 1, 15];
256 230
257 /** @enum {symbol} */ 231 /** @enum {symbol} */
258 Timeline.EventsTimelineTreeView.Filters.Events = { 232 Timeline.EventsTimelineTreeView.Filters.Events = {
259 FilterChanged: Symbol('FilterChanged') 233 FilterChanged: Symbol('FilterChanged')
260 }; 234 };
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/timeline/TimelineTreeView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698