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

Side by Side Diff: Source/devtools/front_end/TimelineFlameChart.js

Issue 183763036: TimelineFlameChart: selectRecord implementation (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebaselined Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/FlameChart.js ('k') | Source/devtools/front_end/TimelinePanel.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 /* 1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved. 2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 /** 179 /**
180 * @param {!WebInspector.TimelineModel.Record} record 180 * @param {!WebInspector.TimelineModel.Record} record
181 * @param {number} level 181 * @param {number} level
182 */ 182 */
183 _appendRecord: function(record, level) 183 _appendRecord: function(record, level)
184 { 184 {
185 var timelineData = this.timelineData(); 185 var timelineData = this.timelineData();
186 186
187 this._startTime = this._startTime ? Math.min(this._startTime, record.sta rtTime) : record.startTime; 187 this._startTime = this._startTime ? Math.min(this._startTime, record.sta rtTime) : record.startTime;
188 this._zeroTime = this._startTime; 188 this._zeroTime = this._startTime;
189 var recordEndTime = record.endTime || record.startTime; 189 var recordEndTime = record.endTime;
190 this._endTime = Math.max(this._endTime, recordEndTime); 190 this._endTime = Math.max(this._endTime, recordEndTime);
191 this._totalTime = Math.max(1000, this._endTime - this._startTime); 191 this._totalTime = Math.max(1000, this._endTime - this._startTime);
192 192
193 if (this._mainThread) { 193 if (this._mainThread) {
194 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask || !!record.thread) 194 if (record.type === WebInspector.TimelineModel.RecordType.GPUTask || !!record.thread)
195 return; 195 return;
196 } else { 196 } else {
197 if (record.type === WebInspector.TimelineModel.RecordType.Program || !record.thread) 197 if (record.type === WebInspector.TimelineModel.RecordType.Program || !record.thread || record.thread === "gpu")
198 return; 198 return;
199 } 199 }
200 200
201 var recordIndex = this._pushRecord(record, true, level, record.startTime , record.endTime);
201 var currentTime = record.startTime; 202 var currentTime = record.startTime;
202 for (var i = 0; i < record.children.length; ++i) { 203 for (var i = 0; i < record.children.length; ++i) {
203 var childRecord = record.children[i]; 204 var childRecord = record.children[i];
204 var childStartTime = childRecord.startTime; 205 var childStartTime = childRecord.startTime;
205 if (currentTime !== childStartTime) 206 var childEndTime = childRecord.endTime;
206 this._pushRecord(record, true, level, currentTime, childStartTim e); 207 if (childStartTime === childEndTime) {
207 var childEndTime = childRecord.endTime || childRecord.startTime; 208 this._appendRecord(childRecord, level + 1);
209 continue;
210 }
211
212 if (currentTime !== childStartTime) {
213 if (recordIndex !== -1) {
214 this._timelineData.entryTotalTimes[recordIndex] = childStart Time - record.startTime;
215 recordIndex = -1;
216 } else {
217 this._pushRecord(record, true, level, currentTime, childStar tTime);
218 }
219 }
208 this._pushRecord(record, false, level, childStartTime, childEndTime) ; 220 this._pushRecord(record, false, level, childStartTime, childEndTime) ;
209 this._appendRecord(childRecord, level + 1); 221 this._appendRecord(childRecord, level + 1);
210 currentTime = childEndTime; 222 currentTime = childEndTime;
211 } 223 }
212 if (recordEndTime !== currentTime || record.children.length === 0) 224 if (recordEndTime !== currentTime || record.children.length === 0)
213 this._pushRecord(record, true, level, currentTime, recordEndTime); 225 this._pushRecord(record, true, level, currentTime, recordEndTime);
214 226
215 this._maxStackDepth = Math.max(this._maxStackDepth, level + 2); 227 this._maxStackDepth = Math.max(this._maxStackDepth, level + 2);
216 }, 228 },
217 229
218 /** 230 /**
219 * @param {!WebInspector.TimelineModel.Record} record 231 * @param {!WebInspector.TimelineModel.Record} record
220 * @param {boolean} isSelfSegment 232 * @param {boolean} isSelfSegment
221 * @param {number} level 233 * @param {number} level
222 * @param {number} startTime 234 * @param {number} startTime
223 * @param {number} endTime 235 * @param {number} endTime
236 * @return {number}
224 */ 237 */
225 _pushRecord: function(record, isSelfSegment, level, startTime, endTime) 238 _pushRecord: function(record, isSelfSegment, level, startTime, endTime)
226 { 239 {
227 var index = this._records.length; 240 var index = this._records.length;
228 this._records.push(record); 241 this._records.push(record);
229 this._timelineData.entryOffsets[index] = startTime - this._zeroTime; 242 this._timelineData.entryOffsets[index] = startTime - this._zeroTime;
230 this._timelineData.entryLevels[index] = level; 243 this._timelineData.entryLevels[index] = level;
231 this._timelineData.entryTotalTimes[index] = endTime - startTime; 244 this._timelineData.entryTotalTimes[index] = endTime - startTime;
232 this._isSelfSegment[index] = isSelfSegment; 245 this._isSelfSegment[index] = isSelfSegment;
246 return index;
233 }, 247 },
234 248
235 /** 249 /**
236 * @param {number} entryIndex 250 * @param {number} entryIndex
237 * @return {?Array.<!{title: string, text: string}>} 251 * @return {?Array.<!{title: string, text: string}>}
238 */ 252 */
239 prepareHighlightedEntryInfo: function(entryIndex) 253 prepareHighlightedEntryInfo: function(entryIndex)
240 { 254 {
241 return null; 255 return null;
242 }, 256 },
243 257
244 /** 258 /**
245 * @param {number} entryIndex 259 * @param {number} entryIndex
246 * @return {boolean} 260 * @return {boolean}
247 */ 261 */
248 canJumpToEntry: function(entryIndex) 262 canJumpToEntry: function(entryIndex)
249 { 263 {
250 return false; 264 return false;
251 }, 265 },
252 266
253 /** 267 /**
254 * @param {number} entryIndex 268 * @param {number} entryIndex
255 * @return {?Object}
256 */
257 entryData: function(entryIndex)
258 {
259 return null;
260 },
261
262 /**
263 * @param {number} entryIndex
264 * @return {!string} 269 * @return {!string}
265 */ 270 */
266 entryColor: function(entryIndex) 271 entryColor: function(entryIndex)
267 { 272 {
268 var category = WebInspector.TimelineUIUtils.categoryForRecord(this._reco rds[entryIndex]); 273 var category = WebInspector.TimelineUIUtils.categoryForRecord(this._reco rds[entryIndex]);
269 return this._isSelfSegment[entryIndex] ? category.fillColorStop1 : categ ory.backgroundColor; 274 return this._isSelfSegment[entryIndex] ? category.fillColorStop1 : categ ory.backgroundColor;
270 }, 275 },
271 276
272 /** 277 /**
278 * @param {number} entryIndex
279 * @return {!{startTimeOffset: number, endTimeOffset: number}}
280 */
281 highlightTimeRange: function(entryIndex)
282 {
283 var record = this._records[entryIndex];
284 return {
285 startTimeOffset: record.startTime - this._zeroTime,
286 endTimeOffset: record.endTime - this._zeroTime
287 };
288 },
289
290 /**
273 * @param {number} entryIndex 291 * @param {number} entryIndex
274 * @return {!string} 292 * @return {!string}
275 */ 293 */
276 textColor: function(entryIndex) 294 textColor: function(entryIndex)
277 { 295 {
278 return "white"; 296 return "white";
279 } 297 }
280 } 298 }
281 299
282 /** 300 /**
283 * @constructor 301 * @constructor
284 * @extends {WebInspector.View} 302 * @extends {WebInspector.View}
285 * @implements {WebInspector.TimelineModeView} 303 * @implements {WebInspector.TimelineModeView}
286 * @implements {WebInspector.TimeRangeController} 304 * @implements {WebInspector.FlameChartDelegate}
287 * @param {!WebInspector.TimelineModeViewDelegate} delegate 305 * @param {!WebInspector.TimelineModeViewDelegate} delegate
288 * @param {!WebInspector.TimelineModel} model 306 * @param {!WebInspector.TimelineModel} model
289 * @param {!WebInspector.TimelineFrameModel} frameModel 307 * @param {!WebInspector.TimelineFrameModel} frameModel
290 * @param {boolean} mainThread 308 * @param {boolean} mainThread
291 */ 309 */
292 WebInspector.TimelineFlameChart = function(delegate, model, frameModel, mainThre ad) 310 WebInspector.TimelineFlameChart = function(delegate, model, frameModel, mainThre ad)
293 { 311 {
294 WebInspector.View.call(this); 312 WebInspector.View.call(this);
313 this.element.classList.add("timeline-flamechart");
314 this.registerRequiredCSS("flameChart.css");
295 this._delegate = delegate; 315 this._delegate = delegate;
296 this._model = model; 316 this._model = model;
297 this._dataProvider = new WebInspector.TimelineFlameChartDataProvider(model, frameModel, mainThread); 317 this._dataProvider = new WebInspector.TimelineFlameChartDataProvider(model, frameModel, mainThread);
298 this._mainView = new WebInspector.FlameChart.MainPane(this._dataProvider, th is, true, true); 318 this._mainView = new WebInspector.FlameChart.MainPane(this._dataProvider, th is, true, true);
299 this._mainView.show(this.element); 319 this._mainView.show(this.element);
300 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this); 320 this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStar ted, this._onRecordingStarted, this);
321 this._mainView.addEventListener(WebInspector.FlameChart.Events.EntrySelected , this._onEntrySelected, this);
301 } 322 }
302 323
303 WebInspector.TimelineFlameChart.prototype = { 324 WebInspector.TimelineFlameChart.prototype = {
304 /** 325 /**
305 * @param {number} windowStartTime 326 * @param {number} windowStartTime
306 * @param {number} windowEndTime 327 * @param {number} windowEndTime
307 */ 328 */
308 requestWindowTimes: function(windowStartTime, windowEndTime) 329 requestWindowTimes: function(windowStartTime, windowEndTime)
309 { 330 {
310 this._delegate.requestWindowTimes(windowStartTime, windowEndTime); 331 this._delegate.requestWindowTimes(windowStartTime, windowEndTime);
311 }, 332 },
312 333
313 /** 334 /**
314 * @param {?RegExp} textFilter 335 * @param {?RegExp} textFilter
315 */ 336 */
316 refreshRecords: function(textFilter) 337 refreshRecords: function(textFilter)
317 { 338 {
318 this._dataProvider.reset(); 339 this._dataProvider.reset();
319 this._mainView._scheduleUpdate(); 340 this._mainView.reset();
341 this.setSelectedRecord(this._selectedRecord);
320 }, 342 },
321 343
322 reset: function() 344 reset: function()
323 { 345 {
324 this._automaticallySizeWindow = true; 346 this._automaticallySizeWindow = true;
325 this._dataProvider.reset(); 347 this._dataProvider.reset();
326 this._mainView.setWindowTimes(0, Infinity); 348 this._mainView.setWindowTimes(0, Infinity);
349 delete this._selectedRecord;
327 }, 350 },
328 351
329 _onRecordingStarted: function() 352 _onRecordingStarted: function()
330 { 353 {
331 this._automaticallySizeWindow = true; 354 this._automaticallySizeWindow = true;
332 }, 355 },
333 356
334 /** 357 /**
335 * @param {!WebInspector.TimelineModel.Record} record 358 * @param {!WebInspector.TimelineModel.Record} record
336 */ 359 */
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 */ 405 */
383 highlightSearchResult: function(record, regex, selectRecord) 406 highlightSearchResult: function(record, regex, selectRecord)
384 { 407 {
385 }, 408 },
386 409
387 /** 410 /**
388 * @param {?WebInspector.TimelineModel.Record} record 411 * @param {?WebInspector.TimelineModel.Record} record
389 */ 412 */
390 setSelectedRecord: function(record) 413 setSelectedRecord: function(record)
391 { 414 {
415 this._selectedRecord = record;
416 var entryRecords = this._dataProvider._records;
417 for (var entryIndex = 0; entryIndex < entryRecords.length; ++entryIndex) {
418 if (entryRecords[entryIndex] === record) {
419 this._mainView.setSelectedEntry(entryIndex);
420 return;
421 }
422 }
423 this._mainView.setSelectedEntry(-1);
424 if (this._selectedElement) {
425 this._selectedElement.remove();
426 delete this._selectedElement;
427 }
428 },
429
430 /**
431 * @param {!WebInspector.Event} event
432 */
433 _onEntrySelected: function(event)
434 {
435 var entryIndex = event.data;
436 var record = this._dataProvider._records[entryIndex];
437 this._delegate.selectRecord(record);
392 }, 438 },
393 439
394 __proto__: WebInspector.View.prototype 440 __proto__: WebInspector.View.prototype
395 } 441 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/FlameChart.js ('k') | Source/devtools/front_end/TimelinePanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698