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

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

Issue 219383003: Improve number formatting in allocation view (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@viewport
Patch Set: Created 6 years, 8 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 | Source/devtools/front_end/heapProfiler.css » ('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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 return null; 223 return null;
224 }, 224 },
225 225
226 /** 226 /**
227 * @param {string} columnIdentifier 227 * @param {string} columnIdentifier
228 * @return {!Element} 228 * @return {!Element}
229 */ 229 */
230 _createValueCell: function(columnIdentifier) 230 _createValueCell: function(columnIdentifier)
231 { 231 {
232 var cell = document.createElement("td"); 232 var cell = document.createElement("td");
233 cell.className = columnIdentifier + "-column"; 233 cell.className = "numeric-column";
234 if (this.dataGrid.snapshot.totalSize !== 0) { 234 if (this.dataGrid.snapshot.totalSize !== 0) {
235 var div = document.createElement("div"); 235 var div = document.createElement("div");
236 var valueSpan = document.createElement("span"); 236 var valueSpan = document.createElement("span");
237 valueSpan.textContent = this.data[columnIdentifier]; 237 valueSpan.textContent = this.data[columnIdentifier];
238 div.appendChild(valueSpan); 238 div.appendChild(valueSpan);
239 var percentColumn = columnIdentifier + "-percent"; 239 var percentColumn = columnIdentifier + "-percent";
240 if (percentColumn in this.data) { 240 if (percentColumn in this.data) {
241 var percentSpan = document.createElement("span"); 241 var percentSpan = document.createElement("span");
242 percentSpan.className = "percent-column"; 242 percentSpan.className = "percent-column";
243 percentSpan.textContent = this.data[percentColumn]; 243 percentSpan.textContent = this.data[percentColumn];
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 createProvider: function() 1178 createProvider: function()
1179 { 1179 {
1180 var tree = this._dataGrid; 1180 var tree = this._dataGrid;
1181 return new WebInspector.HeapSnapshotDiffNodesProvider( 1181 return new WebInspector.HeapSnapshotDiffNodesProvider(
1182 tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._ name), 1182 tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._ name),
1183 tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes), 1183 tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes),
1184 this._addedCount, 1184 this._addedCount,
1185 this._removedCount); 1185 this._removedCount);
1186 }, 1186 },
1187 1187
1188 /**
1189 * @param {string} columnIdentifier
1190 * @return {!Element}
1191 */
1192 createCell: function(columnIdentifier)
1193 {
1194 var cell = WebInspector.HeapSnapshotGridNode.prototype.createCell.call(t his, columnIdentifier);
1195 if (columnIdentifier !== "object")
1196 cell.classList.add("numeric-column");
1197 return cell;
1198 },
1199
1188 _createChildNode: function(item) 1200 _createChildNode: function(item)
1189 { 1201 {
1190 if (item.isAddedNotRemoved) 1202 if (item.isAddedNotRemoved)
1191 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.snapshot, item, false); 1203 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.snapshot, item, false);
1192 else 1204 else
1193 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.baseSnapshot, item, true); 1205 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.baseSnapshot, item, true);
1194 }, 1206 },
1195 1207
1196 _childHashForEntity: function(node) 1208 _childHashForEntity: function(node)
1197 { 1209 {
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 /** 1355 /**
1344 * @constructor 1356 * @constructor
1345 * @extends {WebInspector.HeapSnapshotGridNode} 1357 * @extends {WebInspector.HeapSnapshotGridNode}
1346 * @param {!WebInspector.AllocationDataGrid} dataGrid 1358 * @param {!WebInspector.AllocationDataGrid} dataGrid
1347 * @param {!WebInspector.HeapSnapshotCommon.SerializedAllocationNode} data 1359 * @param {!WebInspector.HeapSnapshotCommon.SerializedAllocationNode} data
1348 */ 1360 */
1349 WebInspector.AllocationGridNode = function(dataGrid, data) 1361 WebInspector.AllocationGridNode = function(dataGrid, data)
1350 { 1362 {
1351 WebInspector.HeapSnapshotGridNode.call(this, dataGrid, data.hasChildren); 1363 WebInspector.HeapSnapshotGridNode.call(this, dataGrid, data.hasChildren);
1352 this._populated = false; 1364 this._populated = false;
1353 this.data = data; 1365 this._allocationNode = data;
1366 this.data = {
1367 "liveCount": Number.withThousandsSeparator(data.liveCount),
1368 "count": Number.withThousandsSeparator(data.count),
1369 "liveSize": Number.withThousandsSeparator(data.liveSize),
1370 "size": Number.withThousandsSeparator(data.size),
1371 "name": data.name
1372 };
1354 } 1373 }
1355 1374
1356 WebInspector.AllocationGridNode.prototype = { 1375 WebInspector.AllocationGridNode.prototype = {
1357 populate: function() 1376 populate: function()
1358 { 1377 {
1359 if (this._populated) 1378 if (this._populated)
1360 return; 1379 return;
1361 this._populated = true; 1380 this._populated = true;
1362 this._dataGrid.snapshot.allocationNodeCallers(this.data.id, didReceiveCa llers.bind(this)); 1381 this._dataGrid.snapshot.allocationNodeCallers(this._allocationNode.id, d idReceiveCallers.bind(this));
1363 1382
1364 /** 1383 /**
1365 * @param {!WebInspector.HeapSnapshotCommon.AllocationNodeCallers} calle rs 1384 * @param {!WebInspector.HeapSnapshotCommon.AllocationNodeCallers} calle rs
1366 * @this {WebInspector.AllocationGridNode} 1385 * @this {WebInspector.AllocationGridNode}
1367 */ 1386 */
1368 function didReceiveCallers(callers) 1387 function didReceiveCallers(callers)
1369 { 1388 {
1370 var callersChain = callers.nodesWithSingleCaller; 1389 var callersChain = callers.nodesWithSingleCaller;
1371 var parentNode = this; 1390 var parentNode = this;
1372 var dataGrid = /** @type {!WebInspector.AllocationDataGrid} */ (this ._dataGrid); 1391 var dataGrid = /** @type {!WebInspector.AllocationDataGrid} */ (this ._dataGrid);
(...skipping 24 matching lines...) Expand all
1397 this.children[0].expand(); 1416 this.children[0].expand();
1398 }, 1417 },
1399 1418
1400 /** 1419 /**
1401 * @override 1420 * @override
1402 * @param {string} columnIdentifier 1421 * @param {string} columnIdentifier
1403 * @return {!Element} 1422 * @return {!Element}
1404 */ 1423 */
1405 createCell: function(columnIdentifier) 1424 createCell: function(columnIdentifier)
1406 { 1425 {
1426 if (columnIdentifier !== "name")
1427 return this._createValueCell(columnIdentifier);
1428
1407 var cell = WebInspector.HeapSnapshotGridNode.prototype.createCell.call(t his, columnIdentifier); 1429 var cell = WebInspector.HeapSnapshotGridNode.prototype.createCell.call(t his, columnIdentifier);
1408 1430 var allocationNode = this._allocationNode;
1409 if (columnIdentifier !== "name") 1431 if (allocationNode.scriptName) {
1410 return cell; 1432 var urlElement = this._dataGrid._linkifier.linkifyLocation(allocatio nNode.scriptName, allocationNode.line - 1, allocationNode.column - 1, "profile-n ode-file");
1411
1412 var functionInfo = this.data;
1413 if (functionInfo.scriptName) {
1414 var urlElement = this._dataGrid._linkifier.linkifyLocation(functionI nfo.scriptName, functionInfo.line - 1, functionInfo.column - 1, "profile-node-fi le");
1415 urlElement.style.maxWidth = "75%"; 1433 urlElement.style.maxWidth = "75%";
1416 cell.insertBefore(urlElement, cell.firstChild); 1434 cell.insertBefore(urlElement, cell.firstChild);
1417 } 1435 }
1418 1436
1419 return cell; 1437 return cell;
1420 }, 1438 },
1421 1439
1422 /** 1440 /**
1423 * @return {number} 1441 * @return {number}
1424 */ 1442 */
1425 allocationNodeId: function() 1443 allocationNodeId: function()
1426 { 1444 {
1427 return this.data.id; 1445 return this.data.id;
1428 }, 1446 },
1429 1447
1430 __proto__: WebInspector.HeapSnapshotGridNode.prototype 1448 __proto__: WebInspector.HeapSnapshotGridNode.prototype
1431 } 1449 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/heapProfiler.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698