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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/profiler/HeapSnapshotGridNodes.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 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 unified diff | Download patch
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.HeapSnapshotGridNode = class extends WebInspector.DataGridNode { 34 Profiler.HeapSnapshotGridNode = class extends UI.DataGridNode {
35 /** 35 /**
36 * @param {!WebInspector.HeapSnapshotSortableDataGrid} tree 36 * @param {!Profiler.HeapSnapshotSortableDataGrid} tree
37 * @param {boolean} hasChildren 37 * @param {boolean} hasChildren
38 */ 38 */
39 constructor(tree, hasChildren) { 39 constructor(tree, hasChildren) {
40 super(null, hasChildren); 40 super(null, hasChildren);
41 this._dataGrid = tree; 41 this._dataGrid = tree;
42 this._instanceCount = 0; 42 this._instanceCount = 0;
43 43
44 this._savedChildren = null; 44 this._savedChildren = null;
45 /** 45 /**
46 * List of position ranges for all visible nodes: [startPos1, endPos1),...,[ startPosN, endPosN) 46 * List of position ranges for all visible nodes: [startPos1, endPos1),...,[ startPosN, endPosN)
47 * Position is an item position in the provider. 47 * Position is an item position in the provider.
48 */ 48 */
49 this._retrievedChildrenRanges = []; 49 this._retrievedChildrenRanges = [];
50 50
51 /** 51 /**
52 * @type {?WebInspector.HeapSnapshotGridNode.ChildrenProvider} 52 * @type {?Profiler.HeapSnapshotGridNode.ChildrenProvider}
53 */ 53 */
54 this._providerObject = null; 54 this._providerObject = null;
55 this._reachableFromWindow = false; 55 this._reachableFromWindow = false;
56 } 56 }
57 57
58 /** 58 /**
59 * @param {!Array.<string>} fieldNames 59 * @param {!Array.<string>} fieldNames
60 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig} 60 * @return {!Profiler.HeapSnapshotCommon.ComparatorConfig}
61 */ 61 */
62 static createComparator(fieldNames) { 62 static createComparator(fieldNames) {
63 return /** @type {!WebInspector.HeapSnapshotCommon.ComparatorConfig} */ ( 63 return /** @type {!Profiler.HeapSnapshotCommon.ComparatorConfig} */ (
64 {fieldName1: fieldNames[0], ascending1: fieldNames[1], fieldName2: field Names[2], ascending2: fieldNames[3]}); 64 {fieldName1: fieldNames[0], ascending1: fieldNames[1], fieldName2: field Names[2], ascending2: fieldNames[3]});
65 } 65 }
66 66
67 /** 67 /**
68 * @return {!WebInspector.HeapSnapshotSortableDataGrid} 68 * @return {!Profiler.HeapSnapshotSortableDataGrid}
69 */ 69 */
70 heapSnapshotDataGrid() { 70 heapSnapshotDataGrid() {
71 return this._dataGrid; 71 return this._dataGrid;
72 } 72 }
73 73
74 /** 74 /**
75 * @return {!WebInspector.HeapSnapshotGridNode.ChildrenProvider} 75 * @return {!Profiler.HeapSnapshotGridNode.ChildrenProvider}
76 */ 76 */
77 createProvider() { 77 createProvider() {
78 throw new Error('Not implemented.'); 78 throw new Error('Not implemented.');
79 } 79 }
80 80
81 /** 81 /**
82 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:numb er}} 82 * @return {?{snapshot:!Profiler.HeapSnapshotProxy, snapshotNodeIndex:number}}
83 */ 83 */
84 retainersDataSource() { 84 retainersDataSource() {
85 return null; 85 return null;
86 } 86 }
87 87
88 /** 88 /**
89 * @return {!WebInspector.HeapSnapshotGridNode.ChildrenProvider} 89 * @return {!Profiler.HeapSnapshotGridNode.ChildrenProvider}
90 */ 90 */
91 _provider() { 91 _provider() {
92 if (!this._providerObject) 92 if (!this._providerObject)
93 this._providerObject = this.createProvider(); 93 this._providerObject = this.createProvider();
94 return this._providerObject; 94 return this._providerObject;
95 } 95 }
96 96
97 /** 97 /**
98 * @override 98 * @override
99 * @param {string} columnId 99 * @param {string} columnId
(...skipping 24 matching lines...) Expand all
124 124
125 dispose() { 125 dispose() {
126 if (this._providerObject) 126 if (this._providerObject)
127 this._providerObject.dispose(); 127 this._providerObject.dispose();
128 for (var node = this.children[0]; node; node = node.traverseNextNode(true, t his, true)) 128 for (var node = this.children[0]; node; node = node.traverseNextNode(true, t his, true))
129 if (node.dispose) 129 if (node.dispose)
130 node.dispose(); 130 node.dispose();
131 } 131 }
132 132
133 /** 133 /**
134 * @param {!WebInspector.Target} target 134 * @param {!SDK.Target} target
135 * @param {function(!WebInspector.RemoteObject)} callback 135 * @param {function(!SDK.RemoteObject)} callback
136 * @param {string} objectGroupName 136 * @param {string} objectGroupName
137 */ 137 */
138 queryObjectContent(target, callback, objectGroupName) { 138 queryObjectContent(target, callback, objectGroupName) {
139 } 139 }
140 140
141 /** 141 /**
142 * @override 142 * @override
143 */ 143 */
144 wasDetached() { 144 wasDetached() {
145 this._dataGrid.nodeWasDetached(this); 145 this._dataGrid.nodeWasDetached(this);
146 } 146 }
147 147
148 /** 148 /**
149 * @param {number} num 149 * @param {number} num
150 * @return {string} 150 * @return {string}
151 */ 151 */
152 _toPercentString(num) { 152 _toPercentString(num) {
153 return num.toFixed(0) + '\u2009%'; // \u2009 is a thin space. 153 return num.toFixed(0) + '\u2009%'; // \u2009 is a thin space.
154 } 154 }
155 155
156 /** 156 /**
157 * @param {number} distance 157 * @param {number} distance
158 * @return {string} 158 * @return {string}
159 */ 159 */
160 _toUIDistance(distance) { 160 _toUIDistance(distance) {
161 var baseSystemDistance = WebInspector.HeapSnapshotCommon.baseSystemDistance; 161 var baseSystemDistance = Profiler.HeapSnapshotCommon.baseSystemDistance;
162 return distance >= 0 && distance < baseSystemDistance ? WebInspector.UIStrin g('%d', distance) : 162 return distance >= 0 && distance < baseSystemDistance ? Common.UIString('%d' , distance) :
163 WebInspector.UIStrin g('\u2212'); 163 Common.UIString('\u2 212');
164 } 164 }
165 165
166 /** 166 /**
167 * @return {!Array.<!WebInspector.DataGridNode>} 167 * @return {!Array.<!UI.DataGridNode>}
168 */ 168 */
169 allChildren() { 169 allChildren() {
170 return this._dataGrid.allChildren(this); 170 return this._dataGrid.allChildren(this);
171 } 171 }
172 172
173 /** 173 /**
174 * @param {number} index 174 * @param {number} index
175 */ 175 */
176 removeChildByIndex(index) { 176 removeChildByIndex(index) {
177 this._dataGrid.removeChildByIndex(this, index); 177 this._dataGrid.removeChildByIndex(this, index);
178 } 178 }
179 179
180 /** 180 /**
181 * @param {number} nodePosition 181 * @param {number} nodePosition
182 * @return {?WebInspector.DataGridNode} 182 * @return {?UI.DataGridNode}
183 */ 183 */
184 childForPosition(nodePosition) { 184 childForPosition(nodePosition) {
185 var indexOfFirstChildInRange = 0; 185 var indexOfFirstChildInRange = 0;
186 for (var i = 0; i < this._retrievedChildrenRanges.length; i++) { 186 for (var i = 0; i < this._retrievedChildrenRanges.length; i++) {
187 var range = this._retrievedChildrenRanges[i]; 187 var range = this._retrievedChildrenRanges[i];
188 if (range.from <= nodePosition && nodePosition < range.to) { 188 if (range.from <= nodePosition && nodePosition < range.to) {
189 var childIndex = indexOfFirstChildInRange + nodePosition - range.from; 189 var childIndex = indexOfFirstChildInRange + nodePosition - range.from;
190 return this.allChildren()[childIndex]; 190 return this.allChildren()[childIndex];
191 } 191 }
192 indexOfFirstChildInRange += range.to - range.from + 1; 192 indexOfFirstChildInRange += range.to - range.from + 1;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 * @param {?number=} fromPosition 243 * @param {?number=} fromPosition
244 * @param {?number=} toPosition 244 * @param {?number=} toPosition
245 * @param {function()=} afterPopulate 245 * @param {function()=} afterPopulate
246 */ 246 */
247 _populateChildren(fromPosition, toPosition, afterPopulate) { 247 _populateChildren(fromPosition, toPosition, afterPopulate) {
248 fromPosition = fromPosition || 0; 248 fromPosition = fromPosition || 0;
249 toPosition = toPosition || fromPosition + this._dataGrid.defaultPopulateCoun t(); 249 toPosition = toPosition || fromPosition + this._dataGrid.defaultPopulateCoun t();
250 var firstNotSerializedPosition = fromPosition; 250 var firstNotSerializedPosition = fromPosition;
251 251
252 /** 252 /**
253 * @this {WebInspector.HeapSnapshotGridNode} 253 * @this {Profiler.HeapSnapshotGridNode}
254 */ 254 */
255 function serializeNextChunk() { 255 function serializeNextChunk() {
256 if (firstNotSerializedPosition >= toPosition) 256 if (firstNotSerializedPosition >= toPosition)
257 return; 257 return;
258 var end = Math.min(firstNotSerializedPosition + this._dataGrid.defaultPopu lateCount(), toPosition); 258 var end = Math.min(firstNotSerializedPosition + this._dataGrid.defaultPopu lateCount(), toPosition);
259 this._provider().serializeItemsRange(firstNotSerializedPosition, end, chil drenRetrieved.bind(this)); 259 this._provider().serializeItemsRange(firstNotSerializedPosition, end, chil drenRetrieved.bind(this));
260 firstNotSerializedPosition = end; 260 firstNotSerializedPosition = end;
261 } 261 }
262 262
263 /** 263 /**
264 * @this {WebInspector.HeapSnapshotGridNode} 264 * @this {Profiler.HeapSnapshotGridNode}
265 */ 265 */
266 function insertRetrievedChild(item, insertionIndex) { 266 function insertRetrievedChild(item, insertionIndex) {
267 if (this._savedChildren) { 267 if (this._savedChildren) {
268 var hash = this._childHashForEntity(item); 268 var hash = this._childHashForEntity(item);
269 if (hash in this._savedChildren) { 269 if (hash in this._savedChildren) {
270 this._dataGrid.insertChild(this, this._savedChildren[hash], insertionI ndex); 270 this._dataGrid.insertChild(this, this._savedChildren[hash], insertionI ndex);
271 return; 271 return;
272 } 272 }
273 } 273 }
274 this._dataGrid.insertChild(this, this._createChildNode(item), insertionInd ex); 274 this._dataGrid.insertChild(this, this._createChildNode(item), insertionInd ex);
275 } 275 }
276 276
277 /** 277 /**
278 * @this {WebInspector.HeapSnapshotGridNode} 278 * @this {Profiler.HeapSnapshotGridNode}
279 */ 279 */
280 function insertShowMoreButton(from, to, insertionIndex) { 280 function insertShowMoreButton(from, to, insertionIndex) {
281 var button = new WebInspector.ShowMoreDataGridNode( 281 var button = new UI.ShowMoreDataGridNode(
282 this._populateChildren.bind(this), from, to, this._dataGrid.defaultPop ulateCount()); 282 this._populateChildren.bind(this), from, to, this._dataGrid.defaultPop ulateCount());
283 this._dataGrid.insertChild(this, button, insertionIndex); 283 this._dataGrid.insertChild(this, button, insertionIndex);
284 } 284 }
285 285
286 /** 286 /**
287 * @param {!WebInspector.HeapSnapshotCommon.ItemsRange} itemsRange 287 * @param {!Profiler.HeapSnapshotCommon.ItemsRange} itemsRange
288 * @this {WebInspector.HeapSnapshotGridNode} 288 * @this {Profiler.HeapSnapshotGridNode}
289 */ 289 */
290 function childrenRetrieved(itemsRange) { 290 function childrenRetrieved(itemsRange) {
291 var itemIndex = 0; 291 var itemIndex = 0;
292 var itemPosition = itemsRange.startPosition; 292 var itemPosition = itemsRange.startPosition;
293 var items = itemsRange.items; 293 var items = itemsRange.items;
294 var insertionIndex = 0; 294 var insertionIndex = 0;
295 295
296 if (!this._retrievedChildrenRanges.length) { 296 if (!this._retrievedChildrenRanges.length) {
297 if (itemsRange.startPosition > 0) { 297 if (itemsRange.startPosition > 0) {
298 this._retrievedChildrenRanges.push({from: 0, to: 0}); 298 this._retrievedChildrenRanges.push({from: 0, to: 0});
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 this._instanceCount += items.length; 374 this._instanceCount += items.length;
375 if (firstNotSerializedPosition < toPosition) { 375 if (firstNotSerializedPosition < toPosition) {
376 serializeNextChunk.call(this); 376 serializeNextChunk.call(this);
377 return; 377 return;
378 } 378 }
379 379
380 if (this.expanded) 380 if (this.expanded)
381 this._dataGrid.updateVisibleNodes(true); 381 this._dataGrid.updateVisibleNodes(true);
382 if (afterPopulate) 382 if (afterPopulate)
383 afterPopulate(); 383 afterPopulate();
384 this.dispatchEventToListeners(WebInspector.HeapSnapshotGridNode.Events.Pop ulateComplete); 384 this.dispatchEventToListeners(Profiler.HeapSnapshotGridNode.Events.Populat eComplete);
385 } 385 }
386 serializeNextChunk.call(this); 386 serializeNextChunk.call(this);
387 } 387 }
388 388
389 _saveChildren() { 389 _saveChildren() {
390 this._savedChildren = null; 390 this._savedChildren = null;
391 var children = this.allChildren(); 391 var children = this.allChildren();
392 for (var i = 0, l = children.length; i < l; ++i) { 392 for (var i = 0, l = children.length; i < l; ++i) {
393 var child = children[i]; 393 var child = children[i];
394 if (!child.expanded) 394 if (!child.expanded)
395 continue; 395 continue;
396 if (!this._savedChildren) 396 if (!this._savedChildren)
397 this._savedChildren = {}; 397 this._savedChildren = {};
398 this._savedChildren[this._childHashForNode(child)] = child; 398 this._savedChildren[this._childHashForNode(child)] = child;
399 } 399 }
400 } 400 }
401 401
402 sort() { 402 sort() {
403 this._dataGrid.recursiveSortingEnter(); 403 this._dataGrid.recursiveSortingEnter();
404 404
405 /** 405 /**
406 * @this {WebInspector.HeapSnapshotGridNode} 406 * @this {Profiler.HeapSnapshotGridNode}
407 */ 407 */
408 function afterSort() { 408 function afterSort() {
409 this._saveChildren(); 409 this._saveChildren();
410 this._dataGrid.removeAllChildren(this); 410 this._dataGrid.removeAllChildren(this);
411 this._retrievedChildrenRanges = []; 411 this._retrievedChildrenRanges = [];
412 412
413 /** 413 /**
414 * @this {WebInspector.HeapSnapshotGridNode} 414 * @this {Profiler.HeapSnapshotGridNode}
415 */ 415 */
416 function afterPopulate() { 416 function afterPopulate() {
417 var children = this.allChildren(); 417 var children = this.allChildren();
418 for (var i = 0, l = children.length; i < l; ++i) { 418 for (var i = 0, l = children.length; i < l; ++i) {
419 var child = children[i]; 419 var child = children[i];
420 if (child.expanded) 420 if (child.expanded)
421 child.sort(); 421 child.sort();
422 } 422 }
423 this._dataGrid.recursiveSortingLeave(); 423 this._dataGrid.recursiveSortingLeave();
424 } 424 }
425 var instanceCount = this._instanceCount; 425 var instanceCount = this._instanceCount;
426 this._instanceCount = 0; 426 this._instanceCount = 0;
427 this._populateChildren(0, instanceCount, afterPopulate.bind(this)); 427 this._populateChildren(0, instanceCount, afterPopulate.bind(this));
428 } 428 }
429 429
430 this._provider().sortAndRewind(this.comparator()).then(afterSort.bind(this)) ; 430 this._provider().sortAndRewind(this.comparator()).then(afterSort.bind(this)) ;
431 } 431 }
432 }; 432 };
433 433
434 /** @enum {symbol} */ 434 /** @enum {symbol} */
435 WebInspector.HeapSnapshotGridNode.Events = { 435 Profiler.HeapSnapshotGridNode.Events = {
436 PopulateComplete: Symbol('PopulateComplete') 436 PopulateComplete: Symbol('PopulateComplete')
437 }; 437 };
438 438
439 439
440 /** 440 /**
441 * @interface 441 * @interface
442 */ 442 */
443 WebInspector.HeapSnapshotGridNode.ChildrenProvider = function() {}; 443 Profiler.HeapSnapshotGridNode.ChildrenProvider = function() {};
444 444
445 WebInspector.HeapSnapshotGridNode.ChildrenProvider.prototype = { 445 Profiler.HeapSnapshotGridNode.ChildrenProvider.prototype = {
446 dispose: function() {}, 446 dispose: function() {},
447 447
448 /** 448 /**
449 * @param {number} snapshotObjectId 449 * @param {number} snapshotObjectId
450 * @return {!Promise<number>} 450 * @return {!Promise<number>}
451 */ 451 */
452 nodePosition: function(snapshotObjectId) {}, 452 nodePosition: function(snapshotObjectId) {},
453 453
454 /** 454 /**
455 * @param {function(boolean)} callback 455 * @param {function(boolean)} callback
456 */ 456 */
457 isEmpty: function(callback) {}, 457 isEmpty: function(callback) {},
458 458
459 /** 459 /**
460 * @param {number} startPosition 460 * @param {number} startPosition
461 * @param {number} endPosition 461 * @param {number} endPosition
462 * @param {function(!WebInspector.HeapSnapshotCommon.ItemsRange)} callback 462 * @param {function(!Profiler.HeapSnapshotCommon.ItemsRange)} callback
463 */ 463 */
464 serializeItemsRange: function(startPosition, endPosition, callback) {}, 464 serializeItemsRange: function(startPosition, endPosition, callback) {},
465 465
466 /** 466 /**
467 * @param {!WebInspector.HeapSnapshotCommon.ComparatorConfig} comparator 467 * @param {!Profiler.HeapSnapshotCommon.ComparatorConfig} comparator
468 * @return {!Promise<?>} 468 * @return {!Promise<?>}
469 */ 469 */
470 sortAndRewind: function(comparator) {} 470 sortAndRewind: function(comparator) {}
471 }; 471 };
472 472
473 /** 473 /**
474 * @unrestricted 474 * @unrestricted
475 */ 475 */
476 WebInspector.HeapSnapshotGenericObjectNode = class extends WebInspector.HeapSnap shotGridNode { 476 Profiler.HeapSnapshotGenericObjectNode = class extends Profiler.HeapSnapshotGrid Node {
477 /** 477 /**
478 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid 478 * @param {!Profiler.HeapSnapshotSortableDataGrid} dataGrid
479 * @param {!WebInspector.HeapSnapshotCommon.Node} node 479 * @param {!Profiler.HeapSnapshotCommon.Node} node
480 */ 480 */
481 constructor(dataGrid, node) { 481 constructor(dataGrid, node) {
482 super(dataGrid, false); 482 super(dataGrid, false);
483 // node is null for DataGrid root nodes. 483 // node is null for DataGrid root nodes.
484 if (!node) 484 if (!node)
485 return; 485 return;
486 this._name = node.name; 486 this._name = node.name;
487 this._type = node.type; 487 this._type = node.type;
488 this._distance = node.distance; 488 this._distance = node.distance;
489 this._shallowSize = node.selfSize; 489 this._shallowSize = node.selfSize;
(...skipping 17 matching lines...) Expand all
507 'distance': this._toUIDistance(this._distance), 507 'distance': this._toUIDistance(this._distance),
508 'shallowSize': Number.withThousandsSeparator(this._shallowSize), 508 'shallowSize': Number.withThousandsSeparator(this._shallowSize),
509 'retainedSize': Number.withThousandsSeparator(this._retainedSize), 509 'retainedSize': Number.withThousandsSeparator(this._retainedSize),
510 'shallowSize-percent': this._toPercentString(shallowSizePercent), 510 'shallowSize-percent': this._toPercentString(shallowSizePercent),
511 'retainedSize-percent': this._toPercentString(retainedSizePercent) 511 'retainedSize-percent': this._toPercentString(retainedSizePercent)
512 }; 512 };
513 } 513 }
514 514
515 /** 515 /**
516 * @override 516 * @override
517 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:numb er}} 517 * @return {?{snapshot:!Profiler.HeapSnapshotProxy, snapshotNodeIndex:number}}
518 */ 518 */
519 retainersDataSource() { 519 retainersDataSource() {
520 return {snapshot: this._dataGrid.snapshot, snapshotNodeIndex: this.snapshotN odeIndex}; 520 return {snapshot: this._dataGrid.snapshot, snapshotNodeIndex: this.snapshotN odeIndex};
521 } 521 }
522 522
523 /** 523 /**
524 * @override 524 * @override
525 * @param {string} columnId 525 * @param {string} columnId
526 * @return {!Element} 526 * @return {!Element}
527 */ 527 */
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 cell.style.setProperty('padding-left', (this.depth * this.dataGrid.indentW idth) + 'px'); 596 cell.style.setProperty('padding-left', (this.depth * this.dataGrid.indentW idth) + 'px');
597 cell.heapSnapshotNode = this; 597 cell.heapSnapshotNode = this;
598 return cell; 598 return cell;
599 } 599 }
600 600
601 _prefixObjectCell(div) { 601 _prefixObjectCell(div) {
602 } 602 }
603 603
604 /** 604 /**
605 * @override 605 * @override
606 * @param {!WebInspector.Target} target 606 * @param {!SDK.Target} target
607 * @param {function(!WebInspector.RemoteObject)} callback 607 * @param {function(!SDK.RemoteObject)} callback
608 * @param {string} objectGroupName 608 * @param {string} objectGroupName
609 */ 609 */
610 queryObjectContent(target, callback, objectGroupName) { 610 queryObjectContent(target, callback, objectGroupName) {
611 /** 611 /**
612 * @param {?Protocol.Error} error 612 * @param {?Protocol.Error} error
613 * @param {!Protocol.Runtime.RemoteObject} object 613 * @param {!Protocol.Runtime.RemoteObject} object
614 */ 614 */
615 function formatResult(error, object) { 615 function formatResult(error, object) {
616 if (!error && object.type) 616 if (!error && object.type)
617 callback(target.runtimeModel.createRemoteObject(object)); 617 callback(target.runtimeModel.createRemoteObject(object));
618 else 618 else
619 callback(target.runtimeModel.createRemoteObjectFromPrimitiveValue( 619 callback(target.runtimeModel.createRemoteObjectFromPrimitiveValue(
620 WebInspector.UIString('Preview is not available'))); 620 Common.UIString('Preview is not available')));
621 } 621 }
622 622
623 if (this._type === 'string') 623 if (this._type === 'string')
624 callback(target.runtimeModel.createRemoteObjectFromPrimitiveValue(this._na me)); 624 callback(target.runtimeModel.createRemoteObjectFromPrimitiveValue(this._na me));
625 else 625 else
626 target.heapProfilerAgent().getObjectByHeapObjectId(String(this.snapshotNod eId), objectGroupName, formatResult); 626 target.heapProfilerAgent().getObjectByHeapObjectId(String(this.snapshotNod eId), objectGroupName, formatResult);
627 } 627 }
628 628
629 updateHasChildren() { 629 updateHasChildren() {
630 /** 630 /**
631 * @this {WebInspector.HeapSnapshotGenericObjectNode} 631 * @this {Profiler.HeapSnapshotGenericObjectNode}
632 */ 632 */
633 function isEmptyCallback(isEmpty) { 633 function isEmptyCallback(isEmpty) {
634 this.hasChildren = !isEmpty; 634 this.hasChildren = !isEmpty;
635 } 635 }
636 this._provider().isEmpty(isEmptyCallback.bind(this)); 636 this._provider().isEmpty(isEmptyCallback.bind(this));
637 } 637 }
638 638
639 /** 639 /**
640 * @param {string} fullName 640 * @param {string} fullName
641 * @param {boolean} hasObjectId 641 * @param {boolean} hasObjectId
642 * @return {string} 642 * @return {string}
643 */ 643 */
644 shortenWindowURL(fullName, hasObjectId) { 644 shortenWindowURL(fullName, hasObjectId) {
645 var startPos = fullName.indexOf('/'); 645 var startPos = fullName.indexOf('/');
646 var endPos = hasObjectId ? fullName.indexOf('@') : fullName.length; 646 var endPos = hasObjectId ? fullName.indexOf('@') : fullName.length;
647 if (startPos !== -1 && endPos !== -1) { 647 if (startPos !== -1 && endPos !== -1) {
648 var fullURL = fullName.substring(startPos + 1, endPos).trimLeft(); 648 var fullURL = fullName.substring(startPos + 1, endPos).trimLeft();
649 var url = fullURL.trimURL(); 649 var url = fullURL.trimURL();
650 if (url.length > 40) 650 if (url.length > 40)
651 url = url.trimMiddle(40); 651 url = url.trimMiddle(40);
652 return fullName.substr(0, startPos + 2) + url + fullName.substr(endPos); 652 return fullName.substr(0, startPos + 2) + url + fullName.substr(endPos);
653 } else 653 } else
654 return fullName; 654 return fullName;
655 } 655 }
656 }; 656 };
657 657
658 /** 658 /**
659 * @unrestricted 659 * @unrestricted
660 */ 660 */
661 WebInspector.HeapSnapshotObjectNode = class extends WebInspector.HeapSnapshotGen ericObjectNode { 661 Profiler.HeapSnapshotObjectNode = class extends Profiler.HeapSnapshotGenericObje ctNode {
662 /** 662 /**
663 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid 663 * @param {!Profiler.HeapSnapshotSortableDataGrid} dataGrid
664 * @param {!WebInspector.HeapSnapshotProxy} snapshot 664 * @param {!Profiler.HeapSnapshotProxy} snapshot
665 * @param {!WebInspector.HeapSnapshotCommon.Edge} edge 665 * @param {!Profiler.HeapSnapshotCommon.Edge} edge
666 * @param {?WebInspector.HeapSnapshotObjectNode} parentObjectNode 666 * @param {?Profiler.HeapSnapshotObjectNode} parentObjectNode
667 */ 667 */
668 constructor(dataGrid, snapshot, edge, parentObjectNode) { 668 constructor(dataGrid, snapshot, edge, parentObjectNode) {
669 super(dataGrid, edge.node); 669 super(dataGrid, edge.node);
670 this._referenceName = edge.name; 670 this._referenceName = edge.name;
671 this._referenceType = edge.type; 671 this._referenceType = edge.type;
672 this._edgeIndex = edge.edgeIndex; 672 this._edgeIndex = edge.edgeIndex;
673 this._snapshot = snapshot; 673 this._snapshot = snapshot;
674 674
675 this._parentObjectNode = parentObjectNode; 675 this._parentObjectNode = parentObjectNode;
676 this._cycledWithAncestorGridNode = this._findAncestorWithSameSnapshotNodeId( ); 676 this._cycledWithAncestorGridNode = this._findAncestorWithSameSnapshotNodeId( );
677 if (!this._cycledWithAncestorGridNode) 677 if (!this._cycledWithAncestorGridNode)
678 this.updateHasChildren(); 678 this.updateHasChildren();
679 679
680 var data = this.data; 680 var data = this.data;
681 data['count'] = ''; 681 data['count'] = '';
682 data['addedCount'] = ''; 682 data['addedCount'] = '';
683 data['removedCount'] = ''; 683 data['removedCount'] = '';
684 data['countDelta'] = ''; 684 data['countDelta'] = '';
685 data['addedSize'] = ''; 685 data['addedSize'] = '';
686 data['removedSize'] = ''; 686 data['removedSize'] = '';
687 data['sizeDelta'] = ''; 687 data['sizeDelta'] = '';
688 } 688 }
689 689
690 /** 690 /**
691 * @override 691 * @override
692 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:numb er}} 692 * @return {?{snapshot:!Profiler.HeapSnapshotProxy, snapshotNodeIndex:number}}
693 */ 693 */
694 retainersDataSource() { 694 retainersDataSource() {
695 return {snapshot: this._snapshot, snapshotNodeIndex: this.snapshotNodeIndex} ; 695 return {snapshot: this._snapshot, snapshotNodeIndex: this.snapshotNodeIndex} ;
696 } 696 }
697 697
698 /** 698 /**
699 * @override 699 * @override
700 * @return {!WebInspector.HeapSnapshotProviderProxy} 700 * @return {!Profiler.HeapSnapshotProviderProxy}
701 */ 701 */
702 createProvider() { 702 createProvider() {
703 return this._snapshot.createEdgesProvider(this.snapshotNodeIndex); 703 return this._snapshot.createEdgesProvider(this.snapshotNodeIndex);
704 } 704 }
705 705
706 _findAncestorWithSameSnapshotNodeId() { 706 _findAncestorWithSameSnapshotNodeId() {
707 var ancestor = this._parentObjectNode; 707 var ancestor = this._parentObjectNode;
708 while (ancestor) { 708 while (ancestor) {
709 if (ancestor.snapshotNodeId === this.snapshotNodeId) 709 if (ancestor.snapshotNodeId === this.snapshotNodeId)
710 return ancestor; 710 return ancestor;
711 ancestor = ancestor._parentObjectNode; 711 ancestor = ancestor._parentObjectNode;
712 } 712 }
713 return null; 713 return null;
714 } 714 }
715 715
716 /** 716 /**
717 * @param {!WebInspector.HeapSnapshotCommon.Edge} item 717 * @param {!Profiler.HeapSnapshotCommon.Edge} item
718 * @return {!WebInspector.HeapSnapshotObjectNode} 718 * @return {!Profiler.HeapSnapshotObjectNode}
719 */ 719 */
720 _createChildNode(item) { 720 _createChildNode(item) {
721 return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._snapsho t, item, this); 721 return new Profiler.HeapSnapshotObjectNode(this._dataGrid, this._snapshot, i tem, this);
722 } 722 }
723 723
724 /** 724 /**
725 * @param {!WebInspector.HeapSnapshotCommon.Edge} edge 725 * @param {!Profiler.HeapSnapshotCommon.Edge} edge
726 * @return {number} 726 * @return {number}
727 */ 727 */
728 _childHashForEntity(edge) { 728 _childHashForEntity(edge) {
729 return edge.edgeIndex; 729 return edge.edgeIndex;
730 } 730 }
731 731
732 /** 732 /**
733 * @param {!WebInspector.HeapSnapshotObjectNode} childNode 733 * @param {!Profiler.HeapSnapshotObjectNode} childNode
734 * @return {number} 734 * @return {number}
735 */ 735 */
736 _childHashForNode(childNode) { 736 _childHashForNode(childNode) {
737 return childNode._edgeIndex; 737 return childNode._edgeIndex;
738 } 738 }
739 739
740 /** 740 /**
741 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig} 741 * @return {!Profiler.HeapSnapshotCommon.ComparatorConfig}
742 */ 742 */
743 comparator() { 743 comparator() {
744 var sortAscending = this._dataGrid.isSortOrderAscending(); 744 var sortAscending = this._dataGrid.isSortOrderAscending();
745 var sortColumnId = this._dataGrid.sortColumnId(); 745 var sortColumnId = this._dataGrid.sortColumnId();
746 var sortFields = { 746 var sortFields = {
747 object: ['!edgeName', sortAscending, 'retainedSize', false], 747 object: ['!edgeName', sortAscending, 'retainedSize', false],
748 count: ['!edgeName', true, 'retainedSize', false], 748 count: ['!edgeName', true, 'retainedSize', false],
749 shallowSize: ['selfSize', sortAscending, '!edgeName', true], 749 shallowSize: ['selfSize', sortAscending, '!edgeName', true],
750 retainedSize: ['retainedSize', sortAscending, '!edgeName', true], 750 retainedSize: ['retainedSize', sortAscending, '!edgeName', true],
751 distance: ['distance', sortAscending, '_name', true] 751 distance: ['distance', sortAscending, '_name', true]
752 }[sortColumnId] || 752 }[sortColumnId] ||
753 ['!edgeName', true, 'retainedSize', false]; 753 ['!edgeName', true, 'retainedSize', false];
754 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 754 return Profiler.HeapSnapshotGridNode.createComparator(sortFields);
755 } 755 }
756 756
757 /** 757 /**
758 * @override 758 * @override
759 */ 759 */
760 _prefixObjectCell(div) { 760 _prefixObjectCell(div) {
761 var name = this._referenceName || '(empty)'; 761 var name = this._referenceName || '(empty)';
762 var nameClass = 'name'; 762 var nameClass = 'name';
763 switch (this._referenceType) { 763 switch (this._referenceType) {
764 case 'context': 764 case 'context':
(...skipping 27 matching lines...) Expand all
792 * @return {string} 792 * @return {string}
793 */ 793 */
794 _edgeNodeSeparator() { 794 _edgeNodeSeparator() {
795 return ' :: '; 795 return ' :: ';
796 } 796 }
797 }; 797 };
798 798
799 /** 799 /**
800 * @unrestricted 800 * @unrestricted
801 */ 801 */
802 WebInspector.HeapSnapshotRetainingObjectNode = class extends WebInspector.HeapSn apshotObjectNode { 802 Profiler.HeapSnapshotRetainingObjectNode = class extends Profiler.HeapSnapshotOb jectNode {
803 /** 803 /**
804 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid 804 * @param {!Profiler.HeapSnapshotSortableDataGrid} dataGrid
805 * @param {!WebInspector.HeapSnapshotProxy} snapshot 805 * @param {!Profiler.HeapSnapshotProxy} snapshot
806 * @param {!WebInspector.HeapSnapshotCommon.Edge} edge 806 * @param {!Profiler.HeapSnapshotCommon.Edge} edge
807 * @param {?WebInspector.HeapSnapshotRetainingObjectNode} parentRetainingObjec tNode 807 * @param {?Profiler.HeapSnapshotRetainingObjectNode} parentRetainingObjectNod e
808 */ 808 */
809 constructor(dataGrid, snapshot, edge, parentRetainingObjectNode) { 809 constructor(dataGrid, snapshot, edge, parentRetainingObjectNode) {
810 super(dataGrid, snapshot, edge, parentRetainingObjectNode); 810 super(dataGrid, snapshot, edge, parentRetainingObjectNode);
811 } 811 }
812 812
813 /** 813 /**
814 * @override 814 * @override
815 * @return {!WebInspector.HeapSnapshotProviderProxy} 815 * @return {!Profiler.HeapSnapshotProviderProxy}
816 */ 816 */
817 createProvider() { 817 createProvider() {
818 return this._snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex); 818 return this._snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex);
819 } 819 }
820 820
821 /** 821 /**
822 * @override 822 * @override
823 * @param {!WebInspector.HeapSnapshotCommon.Edge} item 823 * @param {!Profiler.HeapSnapshotCommon.Edge} item
824 * @return {!WebInspector.HeapSnapshotRetainingObjectNode} 824 * @return {!Profiler.HeapSnapshotRetainingObjectNode}
825 */ 825 */
826 _createChildNode(item) { 826 _createChildNode(item) {
827 return new WebInspector.HeapSnapshotRetainingObjectNode(this._dataGrid, this ._snapshot, item, this); 827 return new Profiler.HeapSnapshotRetainingObjectNode(this._dataGrid, this._sn apshot, item, this);
828 } 828 }
829 829
830 /** 830 /**
831 * @override 831 * @override
832 * @return {string} 832 * @return {string}
833 */ 833 */
834 _edgeNodeSeparator() { 834 _edgeNodeSeparator() {
835 return ' in '; 835 return ' in ';
836 } 836 }
837 837
838 /** 838 /**
839 * @override 839 * @override
840 */ 840 */
841 expand() { 841 expand() {
842 this._expandRetainersChain(20); 842 this._expandRetainersChain(20);
843 } 843 }
844 844
845 /** 845 /**
846 * @param {number} maxExpandLevels 846 * @param {number} maxExpandLevels
847 */ 847 */
848 _expandRetainersChain(maxExpandLevels) { 848 _expandRetainersChain(maxExpandLevels) {
849 /** 849 /**
850 * @this {!WebInspector.HeapSnapshotRetainingObjectNode} 850 * @this {!Profiler.HeapSnapshotRetainingObjectNode}
851 */ 851 */
852 function populateComplete() { 852 function populateComplete() {
853 this.removeEventListener(WebInspector.HeapSnapshotGridNode.Events.Populate Complete, populateComplete, this); 853 this.removeEventListener(Profiler.HeapSnapshotGridNode.Events.PopulateComp lete, populateComplete, this);
854 this._expandRetainersChain(maxExpandLevels); 854 this._expandRetainersChain(maxExpandLevels);
855 } 855 }
856 856
857 if (!this._populated) { 857 if (!this._populated) {
858 this.addEventListener(WebInspector.HeapSnapshotGridNode.Events.PopulateCom plete, populateComplete, this); 858 this.addEventListener(Profiler.HeapSnapshotGridNode.Events.PopulateComplet e, populateComplete, this);
859 this.populate(); 859 this.populate();
860 return; 860 return;
861 } 861 }
862 super.expand(); 862 super.expand();
863 if (--maxExpandLevels > 0 && this.children.length > 0) { 863 if (--maxExpandLevels > 0 && this.children.length > 0) {
864 var retainer = this.children[0]; 864 var retainer = this.children[0];
865 if (retainer._distance > 1) { 865 if (retainer._distance > 1) {
866 retainer._expandRetainersChain(maxExpandLevels); 866 retainer._expandRetainersChain(maxExpandLevels);
867 return; 867 return;
868 } 868 }
869 } 869 }
870 this._dataGrid.dispatchEventToListeners(WebInspector.HeapSnapshotRetainmentD ataGrid.Events.ExpandRetainersComplete); 870 this._dataGrid.dispatchEventToListeners(Profiler.HeapSnapshotRetainmentDataG rid.Events.ExpandRetainersComplete);
871 } 871 }
872 }; 872 };
873 873
874 /** 874 /**
875 * @unrestricted 875 * @unrestricted
876 */ 876 */
877 WebInspector.HeapSnapshotInstanceNode = class extends WebInspector.HeapSnapshotG enericObjectNode { 877 Profiler.HeapSnapshotInstanceNode = class extends Profiler.HeapSnapshotGenericOb jectNode {
878 /** 878 /**
879 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid 879 * @param {!Profiler.HeapSnapshotSortableDataGrid} dataGrid
880 * @param {!WebInspector.HeapSnapshotProxy} snapshot 880 * @param {!Profiler.HeapSnapshotProxy} snapshot
881 * @param {!WebInspector.HeapSnapshotCommon.Node} node 881 * @param {!Profiler.HeapSnapshotCommon.Node} node
882 * @param {boolean} isDeletedNode 882 * @param {boolean} isDeletedNode
883 */ 883 */
884 constructor(dataGrid, snapshot, node, isDeletedNode) { 884 constructor(dataGrid, snapshot, node, isDeletedNode) {
885 super(dataGrid, node); 885 super(dataGrid, node);
886 this._baseSnapshotOrSnapshot = snapshot; 886 this._baseSnapshotOrSnapshot = snapshot;
887 this._isDeletedNode = isDeletedNode; 887 this._isDeletedNode = isDeletedNode;
888 this.updateHasChildren(); 888 this.updateHasChildren();
889 889
890 var data = this.data; 890 var data = this.data;
891 data['count'] = ''; 891 data['count'] = '';
892 data['countDelta'] = ''; 892 data['countDelta'] = '';
893 data['sizeDelta'] = ''; 893 data['sizeDelta'] = '';
894 if (this._isDeletedNode) { 894 if (this._isDeletedNode) {
895 data['addedCount'] = ''; 895 data['addedCount'] = '';
896 data['addedSize'] = ''; 896 data['addedSize'] = '';
897 data['removedCount'] = '\u2022'; 897 data['removedCount'] = '\u2022';
898 data['removedSize'] = Number.withThousandsSeparator(this._shallowSize); 898 data['removedSize'] = Number.withThousandsSeparator(this._shallowSize);
899 } else { 899 } else {
900 data['addedCount'] = '\u2022'; 900 data['addedCount'] = '\u2022';
901 data['addedSize'] = Number.withThousandsSeparator(this._shallowSize); 901 data['addedSize'] = Number.withThousandsSeparator(this._shallowSize);
902 data['removedCount'] = ''; 902 data['removedCount'] = '';
903 data['removedSize'] = ''; 903 data['removedSize'] = '';
904 } 904 }
905 } 905 }
906 906
907 /** 907 /**
908 * @override 908 * @override
909 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:numb er}} 909 * @return {?{snapshot:!Profiler.HeapSnapshotProxy, snapshotNodeIndex:number}}
910 */ 910 */
911 retainersDataSource() { 911 retainersDataSource() {
912 return {snapshot: this._baseSnapshotOrSnapshot, snapshotNodeIndex: this.snap shotNodeIndex}; 912 return {snapshot: this._baseSnapshotOrSnapshot, snapshotNodeIndex: this.snap shotNodeIndex};
913 } 913 }
914 914
915 /** 915 /**
916 * @override 916 * @override
917 * @return {!WebInspector.HeapSnapshotProviderProxy} 917 * @return {!Profiler.HeapSnapshotProviderProxy}
918 */ 918 */
919 createProvider() { 919 createProvider() {
920 return this._baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeInd ex); 920 return this._baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeInd ex);
921 } 921 }
922 922
923 /** 923 /**
924 * @param {!WebInspector.HeapSnapshotCommon.Edge} item 924 * @param {!Profiler.HeapSnapshotCommon.Edge} item
925 * @return {!WebInspector.HeapSnapshotObjectNode} 925 * @return {!Profiler.HeapSnapshotObjectNode}
926 */ 926 */
927 _createChildNode(item) { 927 _createChildNode(item) {
928 return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._baseSna pshotOrSnapshot, item, null); 928 return new Profiler.HeapSnapshotObjectNode(this._dataGrid, this._baseSnapsho tOrSnapshot, item, null);
929 } 929 }
930 930
931 /** 931 /**
932 * @param {!WebInspector.HeapSnapshotCommon.Edge} edge 932 * @param {!Profiler.HeapSnapshotCommon.Edge} edge
933 * @return {number} 933 * @return {number}
934 */ 934 */
935 _childHashForEntity(edge) { 935 _childHashForEntity(edge) {
936 return edge.edgeIndex; 936 return edge.edgeIndex;
937 } 937 }
938 938
939 /** 939 /**
940 * @param {!WebInspector.HeapSnapshotObjectNode} childNode 940 * @param {!Profiler.HeapSnapshotObjectNode} childNode
941 * @return {number} 941 * @return {number}
942 */ 942 */
943 _childHashForNode(childNode) { 943 _childHashForNode(childNode) {
944 return childNode._edgeIndex; 944 return childNode._edgeIndex;
945 } 945 }
946 946
947 /** 947 /**
948 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig} 948 * @return {!Profiler.HeapSnapshotCommon.ComparatorConfig}
949 */ 949 */
950 comparator() { 950 comparator() {
951 var sortAscending = this._dataGrid.isSortOrderAscending(); 951 var sortAscending = this._dataGrid.isSortOrderAscending();
952 var sortColumnId = this._dataGrid.sortColumnId(); 952 var sortColumnId = this._dataGrid.sortColumnId();
953 var sortFields = { 953 var sortFields = {
954 object: ['!edgeName', sortAscending, 'retainedSize', false], 954 object: ['!edgeName', sortAscending, 'retainedSize', false],
955 distance: ['distance', sortAscending, 'retainedSize', false], 955 distance: ['distance', sortAscending, 'retainedSize', false],
956 count: ['!edgeName', true, 'retainedSize', false], 956 count: ['!edgeName', true, 'retainedSize', false],
957 addedSize: ['selfSize', sortAscending, '!edgeName', true], 957 addedSize: ['selfSize', sortAscending, '!edgeName', true],
958 removedSize: ['selfSize', sortAscending, '!edgeName', true], 958 removedSize: ['selfSize', sortAscending, '!edgeName', true],
959 shallowSize: ['selfSize', sortAscending, '!edgeName', true], 959 shallowSize: ['selfSize', sortAscending, '!edgeName', true],
960 retainedSize: ['retainedSize', sortAscending, '!edgeName', true] 960 retainedSize: ['retainedSize', sortAscending, '!edgeName', true]
961 }[sortColumnId] || 961 }[sortColumnId] ||
962 ['!edgeName', true, 'retainedSize', false]; 962 ['!edgeName', true, 'retainedSize', false];
963 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 963 return Profiler.HeapSnapshotGridNode.createComparator(sortFields);
964 } 964 }
965 }; 965 };
966 966
967 /** 967 /**
968 * @unrestricted 968 * @unrestricted
969 */ 969 */
970 WebInspector.HeapSnapshotConstructorNode = class extends WebInspector.HeapSnapsh otGridNode { 970 Profiler.HeapSnapshotConstructorNode = class extends Profiler.HeapSnapshotGridNo de {
971 /** 971 /**
972 * @param {!WebInspector.HeapSnapshotConstructorsDataGrid} dataGrid 972 * @param {!Profiler.HeapSnapshotConstructorsDataGrid} dataGrid
973 * @param {string} className 973 * @param {string} className
974 * @param {!WebInspector.HeapSnapshotCommon.Aggregate} aggregate 974 * @param {!Profiler.HeapSnapshotCommon.Aggregate} aggregate
975 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter 975 * @param {!Profiler.HeapSnapshotCommon.NodeFilter} nodeFilter
976 */ 976 */
977 constructor(dataGrid, className, aggregate, nodeFilter) { 977 constructor(dataGrid, className, aggregate, nodeFilter) {
978 super(dataGrid, aggregate.count > 0); 978 super(dataGrid, aggregate.count > 0);
979 this._name = className; 979 this._name = className;
980 this._nodeFilter = nodeFilter; 980 this._nodeFilter = nodeFilter;
981 this._distance = aggregate.distance; 981 this._distance = aggregate.distance;
982 this._count = aggregate.count; 982 this._count = aggregate.count;
983 this._shallowSize = aggregate.self; 983 this._shallowSize = aggregate.self;
984 this._retainedSize = aggregate.maxRet; 984 this._retainedSize = aggregate.maxRet;
985 985
986 var snapshot = dataGrid.snapshot; 986 var snapshot = dataGrid.snapshot;
987 var countPercent = this._count / snapshot.nodeCount * 100.0; 987 var countPercent = this._count / snapshot.nodeCount * 100.0;
988 var retainedSizePercent = this._retainedSize / snapshot.totalSize * 100.0; 988 var retainedSizePercent = this._retainedSize / snapshot.totalSize * 100.0;
989 var shallowSizePercent = this._shallowSize / snapshot.totalSize * 100.0; 989 var shallowSizePercent = this._shallowSize / snapshot.totalSize * 100.0;
990 990
991 this.data = { 991 this.data = {
992 'object': className, 992 'object': className,
993 'count': Number.withThousandsSeparator(this._count), 993 'count': Number.withThousandsSeparator(this._count),
994 'distance': this._toUIDistance(this._distance), 994 'distance': this._toUIDistance(this._distance),
995 'shallowSize': Number.withThousandsSeparator(this._shallowSize), 995 'shallowSize': Number.withThousandsSeparator(this._shallowSize),
996 'retainedSize': Number.withThousandsSeparator(this._retainedSize), 996 'retainedSize': Number.withThousandsSeparator(this._retainedSize),
997 'count-percent': this._toPercentString(countPercent), 997 'count-percent': this._toPercentString(countPercent),
998 'shallowSize-percent': this._toPercentString(shallowSizePercent), 998 'shallowSize-percent': this._toPercentString(shallowSizePercent),
999 'retainedSize-percent': this._toPercentString(retainedSizePercent) 999 'retainedSize-percent': this._toPercentString(retainedSizePercent)
1000 }; 1000 };
1001 } 1001 }
1002 1002
1003 /** 1003 /**
1004 * @override 1004 * @override
1005 * @return {!WebInspector.HeapSnapshotProviderProxy} 1005 * @return {!Profiler.HeapSnapshotProviderProxy}
1006 */ 1006 */
1007 createProvider() { 1007 createProvider() {
1008 return this._dataGrid.snapshot.createNodesProviderForClass(this._name, this. _nodeFilter); 1008 return this._dataGrid.snapshot.createNodesProviderForClass(this._name, this. _nodeFilter);
1009 } 1009 }
1010 1010
1011 /** 1011 /**
1012 * @param {number} snapshotObjectId 1012 * @param {number} snapshotObjectId
1013 * @return {!Promise<!Array<!WebInspector.HeapSnapshotGridNode>>} 1013 * @return {!Promise<!Array<!Profiler.HeapSnapshotGridNode>>}
1014 */ 1014 */
1015 populateNodeBySnapshotObjectId(snapshotObjectId) { 1015 populateNodeBySnapshotObjectId(snapshotObjectId) {
1016 /** 1016 /**
1017 * @this {WebInspector.HeapSnapshotConstructorNode} 1017 * @this {Profiler.HeapSnapshotConstructorNode}
1018 */ 1018 */
1019 function didExpand() { 1019 function didExpand() {
1020 return this._provider().nodePosition(snapshotObjectId).then(didGetNodePosi tion.bind(this)); 1020 return this._provider().nodePosition(snapshotObjectId).then(didGetNodePosi tion.bind(this));
1021 } 1021 }
1022 1022
1023 /** 1023 /**
1024 * @this {WebInspector.HeapSnapshotConstructorNode} 1024 * @this {Profiler.HeapSnapshotConstructorNode}
1025 * @param {number} nodePosition 1025 * @param {number} nodePosition
1026 * @return {!Promise<!Array<!WebInspector.HeapSnapshotGridNode>>} 1026 * @return {!Promise<!Array<!Profiler.HeapSnapshotGridNode>>}
1027 */ 1027 */
1028 function didGetNodePosition(nodePosition) { 1028 function didGetNodePosition(nodePosition) {
1029 if (nodePosition === -1) { 1029 if (nodePosition === -1) {
1030 this.collapse(); 1030 this.collapse();
1031 return Promise.resolve([]); 1031 return Promise.resolve([]);
1032 } else { 1032 } else {
1033 /** 1033 /**
1034 * @param {function(!Array<!WebInspector.HeapSnapshotGridNode>)} fulfill 1034 * @param {function(!Array<!Profiler.HeapSnapshotGridNode>)} fulfill
1035 * @this {WebInspector.HeapSnapshotConstructorNode} 1035 * @this {Profiler.HeapSnapshotConstructorNode}
1036 */ 1036 */
1037 function action(fulfill) { 1037 function action(fulfill) {
1038 this._populateChildren(nodePosition, null, didPopulateChildren.bind(th is, nodePosition, fulfill)); 1038 this._populateChildren(nodePosition, null, didPopulateChildren.bind(th is, nodePosition, fulfill));
1039 } 1039 }
1040 return new Promise(action.bind(this)); 1040 return new Promise(action.bind(this));
1041 } 1041 }
1042 } 1042 }
1043 1043
1044 /** 1044 /**
1045 * @this {WebInspector.HeapSnapshotConstructorNode} 1045 * @this {Profiler.HeapSnapshotConstructorNode}
1046 * @param {number} nodePosition 1046 * @param {number} nodePosition
1047 * @param {function(!Array<!WebInspector.HeapSnapshotGridNode>)} callback 1047 * @param {function(!Array<!Profiler.HeapSnapshotGridNode>)} callback
1048 */ 1048 */
1049 function didPopulateChildren(nodePosition, callback) { 1049 function didPopulateChildren(nodePosition, callback) {
1050 var node = /** @type {?WebInspector.HeapSnapshotGridNode} */ (this.childFo rPosition(nodePosition)); 1050 var node = /** @type {?Profiler.HeapSnapshotGridNode} */ (this.childForPos ition(nodePosition));
1051 callback(node ? [this, node] : []); 1051 callback(node ? [this, node] : []);
1052 } 1052 }
1053 1053
1054 this._dataGrid.resetNameFilter(); 1054 this._dataGrid.resetNameFilter();
1055 return this.expandWithoutPopulate().then(didExpand.bind(this)); 1055 return this.expandWithoutPopulate().then(didExpand.bind(this));
1056 } 1056 }
1057 1057
1058 /** 1058 /**
1059 * @param {string} filterValue 1059 * @param {string} filterValue
1060 * @return {boolean} 1060 * @return {boolean}
1061 */ 1061 */
1062 filteredOut(filterValue) { 1062 filteredOut(filterValue) {
1063 return this._name.toLowerCase().indexOf(filterValue) === -1; 1063 return this._name.toLowerCase().indexOf(filterValue) === -1;
1064 } 1064 }
1065 1065
1066 /** 1066 /**
1067 * @override 1067 * @override
1068 * @param {string} columnId 1068 * @param {string} columnId
1069 * @return {!Element} 1069 * @return {!Element}
1070 */ 1070 */
1071 createCell(columnId) { 1071 createCell(columnId) {
1072 var cell = columnId !== 'object' ? this._createValueCell(columnId) : super.c reateCell(columnId); 1072 var cell = columnId !== 'object' ? this._createValueCell(columnId) : super.c reateCell(columnId);
1073 if (this._searchMatched) 1073 if (this._searchMatched)
1074 cell.classList.add('highlight'); 1074 cell.classList.add('highlight');
1075 return cell; 1075 return cell;
1076 } 1076 }
1077 1077
1078 /** 1078 /**
1079 * @param {!WebInspector.HeapSnapshotCommon.Node} item 1079 * @param {!Profiler.HeapSnapshotCommon.Node} item
1080 * @return {!WebInspector.HeapSnapshotInstanceNode} 1080 * @return {!Profiler.HeapSnapshotInstanceNode}
1081 */ 1081 */
1082 _createChildNode(item) { 1082 _createChildNode(item) {
1083 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, this._dataG rid.snapshot, item, false); 1083 return new Profiler.HeapSnapshotInstanceNode(this._dataGrid, this._dataGrid. snapshot, item, false);
1084 } 1084 }
1085 1085
1086 /** 1086 /**
1087 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig} 1087 * @return {!Profiler.HeapSnapshotCommon.ComparatorConfig}
1088 */ 1088 */
1089 comparator() { 1089 comparator() {
1090 var sortAscending = this._dataGrid.isSortOrderAscending(); 1090 var sortAscending = this._dataGrid.isSortOrderAscending();
1091 var sortColumnId = this._dataGrid.sortColumnId(); 1091 var sortColumnId = this._dataGrid.sortColumnId();
1092 var sortFields = { 1092 var sortFields = {
1093 object: ['name', sortAscending, 'id', true], 1093 object: ['name', sortAscending, 'id', true],
1094 distance: ['distance', sortAscending, 'retainedSize', false], 1094 distance: ['distance', sortAscending, 'retainedSize', false],
1095 count: ['name', true, 'id', true], 1095 count: ['name', true, 'id', true],
1096 shallowSize: ['selfSize', sortAscending, 'id', true], 1096 shallowSize: ['selfSize', sortAscending, 'id', true],
1097 retainedSize: ['retainedSize', sortAscending, 'id', true] 1097 retainedSize: ['retainedSize', sortAscending, 'id', true]
1098 }[sortColumnId]; 1098 }[sortColumnId];
1099 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 1099 return Profiler.HeapSnapshotGridNode.createComparator(sortFields);
1100 } 1100 }
1101 1101
1102 /** 1102 /**
1103 * @param {!WebInspector.HeapSnapshotCommon.Node} node 1103 * @param {!Profiler.HeapSnapshotCommon.Node} node
1104 * @return {number} 1104 * @return {number}
1105 */ 1105 */
1106 _childHashForEntity(node) { 1106 _childHashForEntity(node) {
1107 return node.id; 1107 return node.id;
1108 } 1108 }
1109 1109
1110 /** 1110 /**
1111 * @param {!WebInspector.HeapSnapshotInstanceNode} childNode 1111 * @param {!Profiler.HeapSnapshotInstanceNode} childNode
1112 * @return {number} 1112 * @return {number}
1113 */ 1113 */
1114 _childHashForNode(childNode) { 1114 _childHashForNode(childNode) {
1115 return childNode.snapshotNodeId; 1115 return childNode.snapshotNodeId;
1116 } 1116 }
1117 }; 1117 };
1118 1118
1119 /** 1119 /**
1120 * @implements {WebInspector.HeapSnapshotGridNode.ChildrenProvider} 1120 * @implements {Profiler.HeapSnapshotGridNode.ChildrenProvider}
1121 * @unrestricted 1121 * @unrestricted
1122 */ 1122 */
1123 WebInspector.HeapSnapshotDiffNodesProvider = class { 1123 Profiler.HeapSnapshotDiffNodesProvider = class {
1124 /** 1124 /**
1125 * @param {!WebInspector.HeapSnapshotProviderProxy} addedNodesProvider 1125 * @param {!Profiler.HeapSnapshotProviderProxy} addedNodesProvider
1126 * @param {!WebInspector.HeapSnapshotProviderProxy} deletedNodesProvider 1126 * @param {!Profiler.HeapSnapshotProviderProxy} deletedNodesProvider
1127 * @param {number} addedCount 1127 * @param {number} addedCount
1128 * @param {number} removedCount 1128 * @param {number} removedCount
1129 */ 1129 */
1130 constructor(addedNodesProvider, deletedNodesProvider, addedCount, removedCount ) { 1130 constructor(addedNodesProvider, deletedNodesProvider, addedCount, removedCount ) {
1131 this._addedNodesProvider = addedNodesProvider; 1131 this._addedNodesProvider = addedNodesProvider;
1132 this._deletedNodesProvider = deletedNodesProvider; 1132 this._deletedNodesProvider = deletedNodesProvider;
1133 this._addedCount = addedCount; 1133 this._addedCount = addedCount;
1134 this._removedCount = removedCount; 1134 this._removedCount = removedCount;
1135 } 1135 }
1136 1136
(...skipping 19 matching lines...) Expand all
1156 * @param {function(boolean)} callback 1156 * @param {function(boolean)} callback
1157 */ 1157 */
1158 isEmpty(callback) { 1158 isEmpty(callback) {
1159 callback(false); 1159 callback(false);
1160 } 1160 }
1161 1161
1162 /** 1162 /**
1163 * @override 1163 * @override
1164 * @param {number} beginPosition 1164 * @param {number} beginPosition
1165 * @param {number} endPosition 1165 * @param {number} endPosition
1166 * @param {function(!WebInspector.HeapSnapshotCommon.ItemsRange)} callback 1166 * @param {function(!Profiler.HeapSnapshotCommon.ItemsRange)} callback
1167 */ 1167 */
1168 serializeItemsRange(beginPosition, endPosition, callback) { 1168 serializeItemsRange(beginPosition, endPosition, callback) {
1169 /** 1169 /**
1170 * @param {!WebInspector.HeapSnapshotCommon.ItemsRange} items 1170 * @param {!Profiler.HeapSnapshotCommon.ItemsRange} items
1171 * @this {WebInspector.HeapSnapshotDiffNodesProvider} 1171 * @this {Profiler.HeapSnapshotDiffNodesProvider}
1172 */ 1172 */
1173 function didReceiveAllItems(items) { 1173 function didReceiveAllItems(items) {
1174 items.totalLength = this._addedCount + this._removedCount; 1174 items.totalLength = this._addedCount + this._removedCount;
1175 callback(items); 1175 callback(items);
1176 } 1176 }
1177 1177
1178 /** 1178 /**
1179 * @param {!WebInspector.HeapSnapshotCommon.ItemsRange} addedItems 1179 * @param {!Profiler.HeapSnapshotCommon.ItemsRange} addedItems
1180 * @param {!WebInspector.HeapSnapshotCommon.ItemsRange} itemsRange 1180 * @param {!Profiler.HeapSnapshotCommon.ItemsRange} itemsRange
1181 * @this {WebInspector.HeapSnapshotDiffNodesProvider} 1181 * @this {Profiler.HeapSnapshotDiffNodesProvider}
1182 */ 1182 */
1183 function didReceiveDeletedItems(addedItems, itemsRange) { 1183 function didReceiveDeletedItems(addedItems, itemsRange) {
1184 var items = itemsRange.items; 1184 var items = itemsRange.items;
1185 if (!addedItems.items.length) 1185 if (!addedItems.items.length)
1186 addedItems.startPosition = this._addedCount + itemsRange.startPosition; 1186 addedItems.startPosition = this._addedCount + itemsRange.startPosition;
1187 for (var i = 0; i < items.length; i++) { 1187 for (var i = 0; i < items.length; i++) {
1188 items[i].isAddedNotRemoved = false; 1188 items[i].isAddedNotRemoved = false;
1189 addedItems.items.push(items[i]); 1189 addedItems.items.push(items[i]);
1190 } 1190 }
1191 addedItems.endPosition = this._addedCount + itemsRange.endPosition; 1191 addedItems.endPosition = this._addedCount + itemsRange.endPosition;
1192 didReceiveAllItems.call(this, addedItems); 1192 didReceiveAllItems.call(this, addedItems);
1193 } 1193 }
1194 1194
1195 /** 1195 /**
1196 * @param {!WebInspector.HeapSnapshotCommon.ItemsRange} itemsRange 1196 * @param {!Profiler.HeapSnapshotCommon.ItemsRange} itemsRange
1197 * @this {WebInspector.HeapSnapshotDiffNodesProvider} 1197 * @this {Profiler.HeapSnapshotDiffNodesProvider}
1198 */ 1198 */
1199 function didReceiveAddedItems(itemsRange) { 1199 function didReceiveAddedItems(itemsRange) {
1200 var items = itemsRange.items; 1200 var items = itemsRange.items;
1201 for (var i = 0; i < items.length; i++) 1201 for (var i = 0; i < items.length; i++)
1202 items[i].isAddedNotRemoved = true; 1202 items[i].isAddedNotRemoved = true;
1203 if (itemsRange.endPosition < endPosition) 1203 if (itemsRange.endPosition < endPosition)
1204 return this._deletedNodesProvider.serializeItemsRange( 1204 return this._deletedNodesProvider.serializeItemsRange(
1205 0, endPosition - itemsRange.endPosition, didReceiveDeletedItems.bind (this, itemsRange)); 1205 0, endPosition - itemsRange.endPosition, didReceiveDeletedItems.bind (this, itemsRange));
1206 1206
1207 itemsRange.totalLength = this._addedCount + this._removedCount; 1207 itemsRange.totalLength = this._addedCount + this._removedCount;
1208 didReceiveAllItems.call(this, itemsRange); 1208 didReceiveAllItems.call(this, itemsRange);
1209 } 1209 }
1210 1210
1211 if (beginPosition < this._addedCount) { 1211 if (beginPosition < this._addedCount) {
1212 this._addedNodesProvider.serializeItemsRange(beginPosition, endPosition, d idReceiveAddedItems.bind(this)); 1212 this._addedNodesProvider.serializeItemsRange(beginPosition, endPosition, d idReceiveAddedItems.bind(this));
1213 } else { 1213 } else {
1214 var emptyRange = new WebInspector.HeapSnapshotCommon.ItemsRange(0, 0, 0, [ ]); 1214 var emptyRange = new Profiler.HeapSnapshotCommon.ItemsRange(0, 0, 0, []);
1215 this._deletedNodesProvider.serializeItemsRange( 1215 this._deletedNodesProvider.serializeItemsRange(
1216 beginPosition - this._addedCount, endPosition - this._addedCount, 1216 beginPosition - this._addedCount, endPosition - this._addedCount,
1217 didReceiveDeletedItems.bind(this, emptyRange)); 1217 didReceiveDeletedItems.bind(this, emptyRange));
1218 } 1218 }
1219 } 1219 }
1220 1220
1221 /** 1221 /**
1222 * @override 1222 * @override
1223 * @param {!WebInspector.HeapSnapshotCommon.ComparatorConfig} comparator 1223 * @param {!Profiler.HeapSnapshotCommon.ComparatorConfig} comparator
1224 * @return {!Promise<?>} 1224 * @return {!Promise<?>}
1225 */ 1225 */
1226 sortAndRewind(comparator) { 1226 sortAndRewind(comparator) {
1227 /** 1227 /**
1228 * @this {WebInspector.HeapSnapshotDiffNodesProvider} 1228 * @this {Profiler.HeapSnapshotDiffNodesProvider}
1229 * @return {!Promise<?>} 1229 * @return {!Promise<?>}
1230 */ 1230 */
1231 function afterSort() { 1231 function afterSort() {
1232 return this._deletedNodesProvider.sortAndRewind(comparator); 1232 return this._deletedNodesProvider.sortAndRewind(comparator);
1233 } 1233 }
1234 return this._addedNodesProvider.sortAndRewind(comparator).then(afterSort.bin d(this)); 1234 return this._addedNodesProvider.sortAndRewind(comparator).then(afterSort.bin d(this));
1235 } 1235 }
1236 }; 1236 };
1237 1237
1238 /** 1238 /**
1239 * @unrestricted 1239 * @unrestricted
1240 */ 1240 */
1241 WebInspector.HeapSnapshotDiffNode = class extends WebInspector.HeapSnapshotGridN ode { 1241 Profiler.HeapSnapshotDiffNode = class extends Profiler.HeapSnapshotGridNode {
1242 /** 1242 /**
1243 * @param {!WebInspector.HeapSnapshotDiffDataGrid} dataGrid 1243 * @param {!Profiler.HeapSnapshotDiffDataGrid} dataGrid
1244 * @param {string} className 1244 * @param {string} className
1245 * @param {!WebInspector.HeapSnapshotCommon.DiffForClass} diffForClass 1245 * @param {!Profiler.HeapSnapshotCommon.DiffForClass} diffForClass
1246 */ 1246 */
1247 constructor(dataGrid, className, diffForClass) { 1247 constructor(dataGrid, className, diffForClass) {
1248 super(dataGrid, true); 1248 super(dataGrid, true);
1249 this._name = className; 1249 this._name = className;
1250 this._addedCount = diffForClass.addedCount; 1250 this._addedCount = diffForClass.addedCount;
1251 this._removedCount = diffForClass.removedCount; 1251 this._removedCount = diffForClass.removedCount;
1252 this._countDelta = diffForClass.countDelta; 1252 this._countDelta = diffForClass.countDelta;
1253 this._addedSize = diffForClass.addedSize; 1253 this._addedSize = diffForClass.addedSize;
1254 this._removedSize = diffForClass.removedSize; 1254 this._removedSize = diffForClass.removedSize;
1255 this._sizeDelta = diffForClass.sizeDelta; 1255 this._sizeDelta = diffForClass.sizeDelta;
1256 this._deletedIndexes = diffForClass.deletedIndexes; 1256 this._deletedIndexes = diffForClass.deletedIndexes;
1257 this.data = { 1257 this.data = {
1258 'object': className, 1258 'object': className,
1259 'addedCount': Number.withThousandsSeparator(this._addedCount), 1259 'addedCount': Number.withThousandsSeparator(this._addedCount),
1260 'removedCount': Number.withThousandsSeparator(this._removedCount), 1260 'removedCount': Number.withThousandsSeparator(this._removedCount),
1261 'countDelta': this._signForDelta(this._countDelta) + Number.withThousandsS eparator(Math.abs(this._countDelta)), 1261 'countDelta': this._signForDelta(this._countDelta) + Number.withThousandsS eparator(Math.abs(this._countDelta)),
1262 'addedSize': Number.withThousandsSeparator(this._addedSize), 1262 'addedSize': Number.withThousandsSeparator(this._addedSize),
1263 'removedSize': Number.withThousandsSeparator(this._removedSize), 1263 'removedSize': Number.withThousandsSeparator(this._removedSize),
1264 'sizeDelta': this._signForDelta(this._sizeDelta) + Number.withThousandsSep arator(Math.abs(this._sizeDelta)) 1264 'sizeDelta': this._signForDelta(this._sizeDelta) + Number.withThousandsSep arator(Math.abs(this._sizeDelta))
1265 }; 1265 };
1266 } 1266 }
1267 1267
1268 /** 1268 /**
1269 * @override 1269 * @override
1270 * @return {!WebInspector.HeapSnapshotDiffNodesProvider} 1270 * @return {!Profiler.HeapSnapshotDiffNodesProvider}
1271 */ 1271 */
1272 createProvider() { 1272 createProvider() {
1273 var tree = this._dataGrid; 1273 var tree = this._dataGrid;
1274 return new WebInspector.HeapSnapshotDiffNodesProvider( 1274 return new Profiler.HeapSnapshotDiffNodesProvider(
1275 tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._name ), 1275 tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._name ),
1276 tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes), this ._addedCount, this._removedCount); 1276 tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes), this ._addedCount, this._removedCount);
1277 } 1277 }
1278 1278
1279 /** 1279 /**
1280 * @override 1280 * @override
1281 * @param {string} columnId 1281 * @param {string} columnId
1282 * @return {!Element} 1282 * @return {!Element}
1283 */ 1283 */
1284 createCell(columnId) { 1284 createCell(columnId) {
1285 var cell = super.createCell(columnId); 1285 var cell = super.createCell(columnId);
1286 if (columnId !== 'object') 1286 if (columnId !== 'object')
1287 cell.classList.add('numeric-column'); 1287 cell.classList.add('numeric-column');
1288 return cell; 1288 return cell;
1289 } 1289 }
1290 1290
1291 /** 1291 /**
1292 * @param {!WebInspector.HeapSnapshotCommon.Node} item 1292 * @param {!Profiler.HeapSnapshotCommon.Node} item
1293 * @return {!WebInspector.HeapSnapshotInstanceNode} 1293 * @return {!Profiler.HeapSnapshotInstanceNode}
1294 */ 1294 */
1295 _createChildNode(item) { 1295 _createChildNode(item) {
1296 if (item.isAddedNotRemoved) 1296 if (item.isAddedNotRemoved)
1297 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, this._dat aGrid.snapshot, item, false); 1297 return new Profiler.HeapSnapshotInstanceNode(this._dataGrid, this._dataGri d.snapshot, item, false);
1298 else 1298 else
1299 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, this._dat aGrid.baseSnapshot, item, true); 1299 return new Profiler.HeapSnapshotInstanceNode(this._dataGrid, this._dataGri d.baseSnapshot, item, true);
1300 } 1300 }
1301 1301
1302 /** 1302 /**
1303 * @param {!WebInspector.HeapSnapshotCommon.Node} node 1303 * @param {!Profiler.HeapSnapshotCommon.Node} node
1304 * @return {number} 1304 * @return {number}
1305 */ 1305 */
1306 _childHashForEntity(node) { 1306 _childHashForEntity(node) {
1307 return node.id; 1307 return node.id;
1308 } 1308 }
1309 1309
1310 /** 1310 /**
1311 * @param {!WebInspector.HeapSnapshotInstanceNode} childNode 1311 * @param {!Profiler.HeapSnapshotInstanceNode} childNode
1312 * @return {number} 1312 * @return {number}
1313 */ 1313 */
1314 _childHashForNode(childNode) { 1314 _childHashForNode(childNode) {
1315 return childNode.snapshotNodeId; 1315 return childNode.snapshotNodeId;
1316 } 1316 }
1317 1317
1318 /** 1318 /**
1319 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig} 1319 * @return {!Profiler.HeapSnapshotCommon.ComparatorConfig}
1320 */ 1320 */
1321 comparator() { 1321 comparator() {
1322 var sortAscending = this._dataGrid.isSortOrderAscending(); 1322 var sortAscending = this._dataGrid.isSortOrderAscending();
1323 var sortColumnId = this._dataGrid.sortColumnId(); 1323 var sortColumnId = this._dataGrid.sortColumnId();
1324 var sortFields = { 1324 var sortFields = {
1325 object: ['name', sortAscending, 'id', true], 1325 object: ['name', sortAscending, 'id', true],
1326 addedCount: ['name', true, 'id', true], 1326 addedCount: ['name', true, 'id', true],
1327 removedCount: ['name', true, 'id', true], 1327 removedCount: ['name', true, 'id', true],
1328 countDelta: ['name', true, 'id', true], 1328 countDelta: ['name', true, 'id', true],
1329 addedSize: ['selfSize', sortAscending, 'id', true], 1329 addedSize: ['selfSize', sortAscending, 'id', true],
1330 removedSize: ['selfSize', sortAscending, 'id', true], 1330 removedSize: ['selfSize', sortAscending, 'id', true],
1331 sizeDelta: ['selfSize', sortAscending, 'id', true] 1331 sizeDelta: ['selfSize', sortAscending, 'id', true]
1332 }[sortColumnId]; 1332 }[sortColumnId];
1333 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 1333 return Profiler.HeapSnapshotGridNode.createComparator(sortFields);
1334 } 1334 }
1335 1335
1336 /** 1336 /**
1337 * @param {string} filterValue 1337 * @param {string} filterValue
1338 * @return {boolean} 1338 * @return {boolean}
1339 */ 1339 */
1340 filteredOut(filterValue) { 1340 filteredOut(filterValue) {
1341 return this._name.toLowerCase().indexOf(filterValue) === -1; 1341 return this._name.toLowerCase().indexOf(filterValue) === -1;
1342 } 1342 }
1343 1343
1344 _signForDelta(delta) { 1344 _signForDelta(delta) {
1345 if (delta === 0) 1345 if (delta === 0)
1346 return ''; 1346 return '';
1347 if (delta > 0) 1347 if (delta > 0)
1348 return '+'; 1348 return '+';
1349 else 1349 else
1350 return '\u2212'; // Math minus sign, same width as plus. 1350 return '\u2212'; // Math minus sign, same width as plus.
1351 } 1351 }
1352 }; 1352 };
1353 1353
1354 /** 1354 /**
1355 * @unrestricted 1355 * @unrestricted
1356 */ 1356 */
1357 WebInspector.AllocationGridNode = class extends WebInspector.HeapSnapshotGridNod e { 1357 Profiler.AllocationGridNode = class extends Profiler.HeapSnapshotGridNode {
1358 /** 1358 /**
1359 * @param {!WebInspector.AllocationDataGrid} dataGrid 1359 * @param {!Profiler.AllocationDataGrid} dataGrid
1360 * @param {!WebInspector.HeapSnapshotCommon.SerializedAllocationNode} data 1360 * @param {!Profiler.HeapSnapshotCommon.SerializedAllocationNode} data
1361 */ 1361 */
1362 constructor(dataGrid, data) { 1362 constructor(dataGrid, data) {
1363 super(dataGrid, data.hasChildren); 1363 super(dataGrid, data.hasChildren);
1364 this._populated = false; 1364 this._populated = false;
1365 this._allocationNode = data; 1365 this._allocationNode = data;
1366 this.data = { 1366 this.data = {
1367 'liveCount': Number.withThousandsSeparator(data.liveCount), 1367 'liveCount': Number.withThousandsSeparator(data.liveCount),
1368 'count': Number.withThousandsSeparator(data.count), 1368 'count': Number.withThousandsSeparator(data.count),
1369 'liveSize': Number.withThousandsSeparator(data.liveSize), 1369 'liveSize': Number.withThousandsSeparator(data.liveSize),
1370 'size': Number.withThousandsSeparator(data.size), 1370 'size': Number.withThousandsSeparator(data.size),
1371 'name': data.name 1371 'name': data.name
1372 }; 1372 };
1373 } 1373 }
1374 1374
1375 /** 1375 /**
1376 * @override 1376 * @override
1377 */ 1377 */
1378 populate() { 1378 populate() {
1379 if (this._populated) 1379 if (this._populated)
1380 return; 1380 return;
1381 this._populated = true; 1381 this._populated = true;
1382 this._dataGrid.snapshot.allocationNodeCallers(this._allocationNode.id, didRe ceiveCallers.bind(this)); 1382 this._dataGrid.snapshot.allocationNodeCallers(this._allocationNode.id, didRe ceiveCallers.bind(this));
1383 1383
1384 /** 1384 /**
1385 * @param {!WebInspector.HeapSnapshotCommon.AllocationNodeCallers} callers 1385 * @param {!Profiler.HeapSnapshotCommon.AllocationNodeCallers} callers
1386 * @this {WebInspector.AllocationGridNode} 1386 * @this {Profiler.AllocationGridNode}
1387 */ 1387 */
1388 function didReceiveCallers(callers) { 1388 function didReceiveCallers(callers) {
1389 var callersChain = callers.nodesWithSingleCaller; 1389 var callersChain = callers.nodesWithSingleCaller;
1390 var parentNode = this; 1390 var parentNode = this;
1391 var dataGrid = /** @type {!WebInspector.AllocationDataGrid} */ (this._data Grid); 1391 var dataGrid = /** @type {!Profiler.AllocationDataGrid} */ (this._dataGrid );
1392 for (var i = 0; i < callersChain.length; i++) { 1392 for (var i = 0; i < callersChain.length; i++) {
1393 var child = new WebInspector.AllocationGridNode(dataGrid, callersChain[i ]); 1393 var child = new Profiler.AllocationGridNode(dataGrid, callersChain[i]);
1394 dataGrid.appendNode(parentNode, child); 1394 dataGrid.appendNode(parentNode, child);
1395 parentNode = child; 1395 parentNode = child;
1396 parentNode._populated = true; 1396 parentNode._populated = true;
1397 if (this.expanded) 1397 if (this.expanded)
1398 parentNode.expand(); 1398 parentNode.expand();
1399 } 1399 }
1400 1400
1401 var callersBranch = callers.branchingCallers; 1401 var callersBranch = callers.branchingCallers;
1402 callersBranch.sort(this._dataGrid._createComparator()); 1402 callersBranch.sort(this._dataGrid._createComparator());
1403 for (var i = 0; i < callersBranch.length; i++) 1403 for (var i = 0; i < callersBranch.length; i++)
1404 dataGrid.appendNode(parentNode, new WebInspector.AllocationGridNode(data Grid, callersBranch[i])); 1404 dataGrid.appendNode(parentNode, new Profiler.AllocationGridNode(dataGrid , callersBranch[i]));
1405 dataGrid.updateVisibleNodes(true); 1405 dataGrid.updateVisibleNodes(true);
1406 } 1406 }
1407 } 1407 }
1408 1408
1409 /** 1409 /**
1410 * @override 1410 * @override
1411 */ 1411 */
1412 expand() { 1412 expand() {
1413 super.expand(); 1413 super.expand();
1414 if (this.children.length === 1) 1414 if (this.children.length === 1)
(...skipping 23 matching lines...) Expand all
1438 return cell; 1438 return cell;
1439 } 1439 }
1440 1440
1441 /** 1441 /**
1442 * @return {number} 1442 * @return {number}
1443 */ 1443 */
1444 allocationNodeId() { 1444 allocationNodeId() {
1445 return this._allocationNode.id; 1445 return this._allocationNode.id;
1446 } 1446 }
1447 }; 1447 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698