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

Side by Side Diff: Source/devtools/front_end/timeline/TimelineTreeView.js

Issue 1312903005: DevTools: Make functions on timeline tree view point to the right source location (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressing comments. Created 5 years, 3 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/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @param {!WebInspector.TimelineModel} model 8 * @param {!WebInspector.TimelineModel} model
9 */ 9 */
10 WebInspector.TimelineTreeView = function(model) 10 WebInspector.TimelineTreeView = function(model)
11 { 11 {
12 WebInspector.VBox.call(this); 12 WebInspector.VBox.call(this);
13 this.element.classList.add("timeline-tree-view"); 13 this.element.classList.add("timeline-tree-view");
14 14
15 this._model = model; 15 this._model = model;
16 this._linkifier = new WebInspector.Linkifier();
16 var columns = []; 17 var columns = [];
17 columns.push({id: "self", title: WebInspector.UIString("Self Time"), width: "120px", sort: WebInspector.DataGrid.Order.Descending, sortable: true}); 18 columns.push({id: "self", title: WebInspector.UIString("Self Time"), width: "120px", sort: WebInspector.DataGrid.Order.Descending, sortable: true});
18 columns.push({id: "total", title: WebInspector.UIString("Total Time"), width : "120px", sortable: true}); 19 columns.push({id: "total", title: WebInspector.UIString("Total Time"), width : "120px", sortable: true});
19 columns.push({id: "activity", title: WebInspector.UIString("Activity"), disc losure: true, sortable: true}); 20 columns.push({id: "activity", title: WebInspector.UIString("Activity"), disc losure: true, sortable: true});
20 21
21 var nonessentialEvents = [ 22 var nonessentialEvents = [
22 WebInspector.TimelineModel.RecordType.EventDispatch, 23 WebInspector.TimelineModel.RecordType.EventDispatch,
23 WebInspector.TimelineModel.RecordType.FunctionCall, 24 WebInspector.TimelineModel.RecordType.FunctionCall,
24 WebInspector.TimelineModel.RecordType.TimerFire 25 WebInspector.TimelineModel.RecordType.TimerFire
25 ]; 26 ];
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (id === this._groupBySetting.get()) 92 if (id === this._groupBySetting.get())
92 this._groupByCombobox.select(option); 93 this._groupByCombobox.select(option);
93 } 94 }
94 addGroupingOption.call(this, WebInspector.UIString("No Grouping"), WebIn spector.TimelineTreeView.GroupBy.None); 95 addGroupingOption.call(this, WebInspector.UIString("No Grouping"), WebIn spector.TimelineTreeView.GroupBy.None);
95 addGroupingOption.call(this, WebInspector.UIString("Group by Domain"), W ebInspector.TimelineTreeView.GroupBy.Domain); 96 addGroupingOption.call(this, WebInspector.UIString("Group by Domain"), W ebInspector.TimelineTreeView.GroupBy.Domain);
96 addGroupingOption.call(this, WebInspector.UIString("Group by Subdomain") , WebInspector.TimelineTreeView.GroupBy.Subdomain); 97 addGroupingOption.call(this, WebInspector.UIString("Group by Subdomain") , WebInspector.TimelineTreeView.GroupBy.Subdomain);
97 addGroupingOption.call(this, WebInspector.UIString("Group by URL"), WebI nspector.TimelineTreeView.GroupBy.URL); 98 addGroupingOption.call(this, WebInspector.UIString("Group by URL"), WebI nspector.TimelineTreeView.GroupBy.URL);
98 panelToolbar.appendToolbarItem(this._groupByCombobox); 99 panelToolbar.appendToolbarItem(this._groupByCombobox);
99 }, 100 },
100 101
102 /**
103 * @param {?string} scriptId
104 * @param {string} url
105 * @param {number} lineNumber
106 * @param {number=} columnNumber
107 * @return {!Element}
108 */
109 linkifyLocation: function(scriptId, url, lineNumber, columnNumber)
110 {
111 return this._linkifier.linkifyScriptLocation(this._model.target(), scrip tId, url, lineNumber, columnNumber);
112 },
113
101 _onTreeModeChanged: function() 114 _onTreeModeChanged: function()
102 { 115 {
103 this._refreshTree(); 116 this._refreshTree();
104 }, 117 },
105 118
106 _onGroupByChanged: function() 119 _onGroupByChanged: function()
107 { 120 {
108 this._groupBySetting.set(this._groupByCombobox.selectedOption().value); 121 this._groupBySetting.set(this._groupByCombobox.selectedOption().value);
109 this._refreshTree(); 122 this._refreshTree();
110 }, 123 },
111 124
112 _refreshTree: function() 125 _refreshTree: function()
113 { 126 {
127 this._linkifier.reset();
114 this.dataGrid.rootNode().removeChildren(); 128 this.dataGrid.rootNode().removeChildren();
115 var topDown = WebInspector.TimelineModel.buildTopDownTree( 129 var topDown = WebInspector.TimelineModel.buildTopDownTree(
116 this._model.mainThreadEvents(), this._startTime, this._endTime, this ._filters, WebInspector.TimelineTreeView.eventId); 130 this._model.mainThreadEvents(), this._startTime, this._endTime, this ._filters, WebInspector.TimelineTreeView.eventId);
117 var isTopDown = this._modeCombobox.selectedOption().value === WebInspect or.TimelineTreeView.Mode.TopDown; 131 var isTopDown = this._modeCombobox.selectedOption().value === WebInspect or.TimelineTreeView.Mode.TopDown;
118 var tree = isTopDown ? this._preformTopDownTreeGrouping(topDown) : this. _buildBottomUpTree(topDown); 132 var tree = isTopDown ? this._preformTopDownTreeGrouping(topDown) : this. _buildBottomUpTree(topDown);
119 this.dataGrid.markColumnAsSortedBy(isTopDown ? "total" : "self", WebInsp ector.DataGrid.Order.Descending); 133 this.dataGrid.markColumnAsSortedBy(isTopDown ? "total" : "self", WebInsp ector.DataGrid.Order.Descending);
120 var maxSelfTime = 0; 134 var maxSelfTime = 0;
121 var maxTotalTime = 0; 135 var maxTotalTime = 0;
122 for (var child of tree.children.values()) { 136 for (var child of tree.children.values()) {
123 maxSelfTime = Math.max(maxSelfTime, child.selfTime); 137 maxSelfTime = Math.max(maxSelfTime, child.selfTime);
124 maxTotalTime = Math.max(maxTotalTime, child.totalTime); 138 maxTotalTime = Math.max(maxTotalTime, child.totalTime);
125 } 139 }
126 for (var child of tree.children.values()) { 140 for (var child of tree.children.values()) {
127 // Exclude the idle time off the total calculation. 141 // Exclude the idle time off the total calculation.
128 var gridNode = new WebInspector.TimelineTreeView.GridNode(child, top Down.totalTime, maxSelfTime, maxTotalTime); 142 var gridNode = new WebInspector.TimelineTreeView.GridNode(child, top Down.totalTime, maxSelfTime, maxTotalTime, this);
129 this.dataGrid.insertChild(gridNode); 143 this.dataGrid.insertChild(gridNode);
130 } 144 }
131 this._sortingChanged(); 145 this._sortingChanged();
132 }, 146 },
133 147
134 /** 148 /**
135 * @param {!WebInspector.TimelineModel.ProfileTreeNode} topDownTree 149 * @param {!WebInspector.TimelineModel.ProfileTreeNode} topDownTree
136 * @return {!WebInspector.TimelineModel.ProfileTreeNode} 150 * @return {!WebInspector.TimelineModel.ProfileTreeNode}
137 */ 151 */
138 _preformTopDownTreeGrouping: function(topDownTree) 152 _preformTopDownTreeGrouping: function(topDownTree)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 { 292 {
279 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame) { 293 if (event.name === WebInspector.TimelineModel.RecordType.JSFrame) {
280 var data = event.args["data"]; 294 var data = event.args["data"];
281 return "f:" + data["functionName"] + "@" + (data["scriptId"] || data["ur l"] || ""); 295 return "f:" + data["functionName"] + "@" + (data["scriptId"] || data["ur l"] || "");
282 } 296 }
283 return event.name + ":@" + WebInspector.TimelineTreeView.eventURL(event); 297 return event.name + ":@" + WebInspector.TimelineTreeView.eventURL(event);
284 } 298 }
285 299
286 /** 300 /**
287 * @param {!WebInspector.TracingModel.Event} event 301 * @param {!WebInspector.TracingModel.Event} event
302 * @return {?Object}
303 */
304 WebInspector.TimelineTreeView.eventStackFrame = function(event)
305 {
306 var data = event.args["data"] || event.args["beginData"];
307 if (data)
308 return data;
309 var topFrame = event.stackTrace && event.stackTrace[0];
310 if (topFrame)
311 return topFrame;
312 var initiator = event.initiator;
313 return initiator && initiator.stackTrace && initiator.stackTrace[0] || null;
314 }
315
316 /**
317 * @param {!WebInspector.TracingModel.Event} event
288 * @return {?string} 318 * @return {?string}
289 */ 319 */
290 WebInspector.TimelineTreeView.eventURL = function(event) 320 WebInspector.TimelineTreeView.eventURL = function(event)
291 { 321 {
292 var data = event.args["data"] || event.args["beginData"]; 322 var frame = WebInspector.TimelineTreeView.eventStackFrame(event);
293 var url = data && data["url"]; 323 return frame && frame["url"] || null;
294 if (url)
295 return url;
296 var topFrame = event.stackTrace && event.stackTrace[0];
297 url = topFrame && topFrame["url"];
298 if (url)
299 return url;
300 var initiator = event.initiator;
301 var initiatorTopFrame = initiator && initiator.stackTrace && initiator.stack Trace[0];
302 return initiatorTopFrame && initiatorTopFrame["url"] || null;
303 } 324 }
304 325
305 /** 326 /**
306 * @constructor 327 * @constructor
307 * @extends {WebInspector.SortableDataGridNode} 328 * @extends {WebInspector.SortableDataGridNode}
308 * @param {!WebInspector.TimelineModel.ProfileTreeNode} profileNode 329 * @param {!WebInspector.TimelineModel.ProfileTreeNode} profileNode
309 * @param {number} grandTotalTime 330 * @param {number} grandTotalTime
310 * @param {number} maxSelfTime 331 * @param {number} maxSelfTime
311 * @param {number} maxTotalTime 332 * @param {number} maxTotalTime
333 * @param {!WebInspector.TimelineTreeView} treeView
312 */ 334 */
313 WebInspector.TimelineTreeView.GridNode = function(profileNode, grandTotalTime, m axSelfTime, maxTotalTime) 335 WebInspector.TimelineTreeView.GridNode = function(profileNode, grandTotalTime, m axSelfTime, maxTotalTime, treeView)
314 { 336 {
315 /** 337 /**
316 * @param {number} time 338 * @param {number} time
317 * @return {string} 339 * @return {string}
318 */ 340 */
319 function formatMilliseconds(time) 341 function formatMilliseconds(time)
320 { 342 {
321 return WebInspector.UIString("%.1f\u2009ms", time); 343 return WebInspector.UIString("%.1f\u2009ms", time);
322 } 344 }
323 /** 345 /**
324 * @param {number} value 346 * @param {number} value
325 * @return {string} 347 * @return {string}
326 */ 348 */
327 function formatPercent(value) 349 function formatPercent(value)
328 { 350 {
329 return WebInspector.UIString("%.2f\u2009%%", value); 351 return WebInspector.UIString("%.2f\u2009%%", value);
330 } 352 }
331 353
332 this._populated = false; 354 this._populated = false;
333 this._profileNode = profileNode; 355 this._profileNode = profileNode;
356 this._treeView = treeView;
334 this._totalTime = grandTotalTime; 357 this._totalTime = grandTotalTime;
335 this._maxTimes = { self: maxSelfTime, total: maxTotalTime }; 358 this._maxTimes = { self: maxSelfTime, total: maxTotalTime };
336 var selfTime = profileNode.selfTime; 359 var selfTime = profileNode.selfTime;
337 var selfPercent = selfTime / grandTotalTime * 100; 360 var selfPercent = selfTime / grandTotalTime * 100;
338 var totalTime = profileNode.totalTime; 361 var totalTime = profileNode.totalTime;
339 var totalPercent = totalTime / grandTotalTime * 100; 362 var totalPercent = totalTime / grandTotalTime * 100;
340 var data = { 363 var data = {
341 "activity": profileNode.name, 364 "activity": profileNode.name,
342 "self-percent": formatPercent(selfPercent), 365 "self-percent": formatPercent(selfPercent),
343 "self": formatMilliseconds(selfTime), 366 "self": formatMilliseconds(selfTime),
(...skipping 26 matching lines...) Expand all
370 var cell = this.createTD(columnIdentifier); 393 var cell = this.createTD(columnIdentifier);
371 var container = cell.createChild("div", "name-container"); 394 var container = cell.createChild("div", "name-container");
372 var icon = container.createChild("div", "activity-icon"); 395 var icon = container.createChild("div", "activity-icon");
373 var name = container.createChild("div", "activity-name"); 396 var name = container.createChild("div", "activity-name");
374 var link = container.createChild("div", "activity-link"); 397 var link = container.createChild("div", "activity-link");
375 var event = this._profileNode.event; 398 var event = this._profileNode.event;
376 if (event) { 399 if (event) {
377 name.textContent = event.name === WebInspector.TimelineModel.RecordT ype.JSFrame 400 name.textContent = event.name === WebInspector.TimelineModel.RecordT ype.JSFrame
378 ? WebInspector.beautifyFunctionName(event.args["data"]["function Name"]) 401 ? WebInspector.beautifyFunctionName(event.args["data"]["function Name"])
379 : WebInspector.TimelineUIUtils.eventTitle(event); 402 : WebInspector.TimelineUIUtils.eventTitle(event);
380 var url = WebInspector.TimelineTreeView.eventURL(event); 403 var frame = WebInspector.TimelineTreeView.eventStackFrame(event);
404 var scriptId = frame && frame["scriptId"];
405 var url = frame && frame["url"];
406 var lineNumber = frame && frame["lineNumber"] || 1;
407 var columnNumber = frame && frame["columnNumber"];
381 if (url) 408 if (url)
382 link.appendChild(WebInspector.linkifyResourceAsNode(url)); 409 link.appendChild(this._treeView.linkifyLocation(scriptId, url, l ineNumber, columnNumber));
383 var category = WebInspector.TimelineUIUtils.eventStyle(event).catego ry; 410 var category = WebInspector.TimelineUIUtils.eventStyle(event).catego ry;
384 icon.style.backgroundColor = category.fillColorStop1; 411 icon.style.backgroundColor = category.fillColorStop1;
385 } else { 412 } else {
386 name.textContent = this._profileNode.name; 413 name.textContent = this._profileNode.name;
387 icon.style.backgroundColor = WebInspector.TimelineUIUtils.colorForUR L(this._profileNode.name); 414 icon.style.backgroundColor = WebInspector.TimelineUIUtils.colorForUR L(this._profileNode.name);
388 } 415 }
389 return cell; 416 return cell;
390 }, 417 },
391 418
392 /** 419 /**
(...skipping 21 matching lines...) Expand all
414 * @override 441 * @override
415 */ 442 */
416 populate: function() 443 populate: function()
417 { 444 {
418 if (this._populated) 445 if (this._populated)
419 return; 446 return;
420 this._populated = true; 447 this._populated = true;
421 if (!this._profileNode.children) 448 if (!this._profileNode.children)
422 return; 449 return;
423 for (var node of this._profileNode.children.values()) { 450 for (var node of this._profileNode.children.values()) {
424 var gridNode = new WebInspector.TimelineTreeView.GridNode(node, this ._totalTime, this._maxTimes.self, this._maxTimes.total); 451 var gridNode = new WebInspector.TimelineTreeView.GridNode(node, this ._totalTime, this._maxTimes.self, this._maxTimes.total, this._treeView);
425 this.insertChildOrdered(gridNode); 452 this.insertChildOrdered(gridNode);
426 } 453 }
427 }, 454 },
428 455
429 __proto__: WebInspector.SortableDataGridNode.prototype 456 __proto__: WebInspector.SortableDataGridNode.prototype
430 } 457 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698