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

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

Issue 211273005: Do not override data getter in heap snapshot grid nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 WebInspector.HeapSnapshotGridNode.prototype = { 104 WebInspector.HeapSnapshotGridNode.prototype = {
105 /** 105 /**
106 * @return {!WebInspector.HeapSnapshotGridNode.ChildrenProvider} 106 * @return {!WebInspector.HeapSnapshotGridNode.ChildrenProvider}
107 */ 107 */
108 createProvider: function() 108 createProvider: function()
109 { 109 {
110 throw new Error("Not implemented."); 110 throw new Error("Not implemented.");
111 }, 111 },
112 112
113 /** 113 /**
114 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:nu mber}}
115 */
116 retainersDataSource: function()
117 {
118 return null;
119 },
120
121 /**
114 * @return {!WebInspector.HeapSnapshotGridNode.ChildrenProvider} 122 * @return {!WebInspector.HeapSnapshotGridNode.ChildrenProvider}
115 */ 123 */
116 _provider: function() 124 _provider: function()
117 { 125 {
118 if (!this._providerObject) 126 if (!this._providerObject)
119 this._providerObject = this.createProvider(); 127 this._providerObject = this.createProvider();
120 return this._providerObject; 128 return this._providerObject;
121 }, 129 },
122 130
123 /** 131 /**
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 this._provider().sortAndRewind(this.comparator(), afterSort.bind(this)); 470 this._provider().sortAndRewind(this.comparator(), afterSort.bind(this));
463 }, 471 },
464 472
465 __proto__: WebInspector.DataGridNode.prototype 473 __proto__: WebInspector.DataGridNode.prototype
466 } 474 }
467 475
468 476
469 /** 477 /**
470 * @constructor 478 * @constructor
471 * @extends {WebInspector.HeapSnapshotGridNode} 479 * @extends {WebInspector.HeapSnapshotGridNode}
472 * @param {!WebInspector.HeapSnapshotSortableDataGrid} tree 480 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid
473 */ 481 */
474 WebInspector.HeapSnapshotGenericObjectNode = function(tree, node) 482 WebInspector.HeapSnapshotGenericObjectNode = function(dataGrid, node)
475 { 483 {
476 this.snapshotNodeIndex = 0; 484 WebInspector.HeapSnapshotGridNode.call(this, dataGrid, false);
477 WebInspector.HeapSnapshotGridNode.call(this, tree, false);
478 // node is null for DataGrid root nodes. 485 // node is null for DataGrid root nodes.
479 if (!node) 486 if (!node)
480 return; 487 return;
481 this._name = node.name; 488 this._name = node.name;
482 this._type = node.type; 489 this._type = node.type;
483 this._distance = node.distance; 490 this._distance = node.distance;
484 this._shallowSize = node.selfSize; 491 this._shallowSize = node.selfSize;
485 this._retainedSize = node.retainedSize; 492 this._retainedSize = node.retainedSize;
loislo 2014/03/26 08:36:04 Looks like we don't need these 3 properties on 'th
yurys 2014/03/26 09:25:09 They are used when sorting rows, see _sortFields m
486 this.snapshotNodeId = node.id; 493 this.snapshotNodeId = node.id;
487 this.snapshotNodeIndex = node.nodeIndex; 494 this.snapshotNodeIndex = node.nodeIndex;
488 if (this._type === "string") 495 if (this._type === "string")
489 this._reachableFromWindow = true; 496 this._reachableFromWindow = true;
490 else if (this._type === "object" && this._name.startsWith("Window")) { 497 else if (this._type === "object" && this._name.startsWith("Window")) {
491 this._name = this.shortenWindowURL(this._name, false); 498 this._name = this.shortenWindowURL(this._name, false);
492 this._reachableFromWindow = true; 499 this._reachableFromWindow = true;
493 } else if (node.canBeQueried) 500 } else if (node.canBeQueried)
494 this._reachableFromWindow = true; 501 this._reachableFromWindow = true;
495 if (node.detachedDOMTreeNode) 502 if (node.detachedDOMTreeNode)
496 this.detachedDOMTreeNode = true; 503 this.detachedDOMTreeNode = true;
504
505 var snapshot = dataGrid.snapshot;
506 var shallowSizePercent = this._shallowSize / snapshot.totalSize * 100.0;
507 var retainedSizePercent = this._retainedSize / snapshot.totalSize * 100.0;
508 this.data = {
509 "distance": this._distance,
510 "shallowSize": Number.withThousandsSeparator(this._shallowSize),
511 "retainedSize": Number.withThousandsSeparator(this._retainedSize),
512 "shallowSize-percent": this._toPercentString(shallowSizePercent),
513 "retainedSize-percent": this._toPercentString(retainedSizePercent)
514 };
497 }; 515 };
498 516
499 WebInspector.HeapSnapshotGenericObjectNode.prototype = { 517 WebInspector.HeapSnapshotGenericObjectNode.prototype = {
500 /** 518 /**
519 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:nu mber}}
520 */
521 retainersDataSource: function()
522 {
523 return {snapshot: this._dataGrid.snapshot, snapshotNodeIndex: this.snaps hotNodeIndex};
524 },
525
526 /**
501 * @param {string} columnIdentifier 527 * @param {string} columnIdentifier
502 * @return {!Element} 528 * @return {!Element}
503 */ 529 */
504 createCell: function(columnIdentifier) 530 createCell: function(columnIdentifier)
505 { 531 {
506 var cell = columnIdentifier !== "object" ? this._createValueCell(columnI dentifier) : this._createObjectCell(); 532 var cell = columnIdentifier !== "object" ? this._createValueCell(columnI dentifier) : this._createObjectCell();
507 if (this._searchMatched) 533 if (this._searchMatched)
508 cell.classList.add("highlight"); 534 cell.classList.add("highlight");
509 return cell; 535 return cell;
510 }, 536 },
511 537
538 /**
539 * @return {!Element}
540 */
512 _createObjectCell: function() 541 _createObjectCell: function()
513 { 542 {
514 var cell = document.createElement("td");
515 cell.className = "object-column";
516 var div = document.createElement("div");
517 div.className = "source-code event-properties";
518 div.style.overflow = "visible";
519
520 var data = this.data["object"];
521 if (this._prefixObjectCell)
522 this._prefixObjectCell(div, data);
523
524 var valueSpan = document.createElement("span");
525 valueSpan.className = "value console-formatted-" + data.valueStyle;
526 valueSpan.textContent = data.value;
527 div.appendChild(valueSpan);
528
529 var idSpan = document.createElement("span");
530 idSpan.className = "console-formatted-id";
531 idSpan.textContent = " @" + data["nodeId"];
532 div.appendChild(idSpan);
533
534 if (this._postfixObjectCell)
535 this._postfixObjectCell(div, data);
536
537 cell.appendChild(div);
538 cell.classList.add("disclosure");
539 if (this.depth)
540 cell.style.setProperty("padding-left", (this.depth * this.dataGrid.i ndentWidth) + "px");
541 cell.heapSnapshotNode = this;
542 return cell;
543 },
544
545 get data()
546 {
547 var data = this._emptyData();
548
549 var value = this._name; 543 var value = this._name;
550 var valueStyle = "object"; 544 var valueStyle = "object";
551 switch (this._type) { 545 switch (this._type) {
552 case "concatenated string": 546 case "concatenated string":
553 case "string": 547 case "string":
554 value = "\"" + value + "\""; 548 value = "\"" + value + "\"";
555 valueStyle = "string"; 549 valueStyle = "string";
556 break; 550 break;
557 case "regexp": 551 case "regexp":
558 value = "/" + value + "/"; 552 value = "/" + value + "/";
(...skipping 15 matching lines...) Expand all
574 else 568 else
575 value += "[]"; 569 value += "[]";
576 break; 570 break;
577 }; 571 };
578 if (this._reachableFromWindow) 572 if (this._reachableFromWindow)
579 valueStyle += " highlight"; 573 valueStyle += " highlight";
580 if (value === "Object") 574 if (value === "Object")
581 value = ""; 575 value = "";
582 if (this.detachedDOMTreeNode) 576 if (this.detachedDOMTreeNode)
583 valueStyle += " detached-dom-tree-node"; 577 valueStyle += " detached-dom-tree-node";
584 data["object"] = { valueStyle: valueStyle, value: value, nodeId: this.sn apshotNodeId }; 578 return this._createObjectCellWithValue(valueStyle, value);
579 },
585 580
586 data["distance"] = this._distance; 581 _createObjectCellWithValue: function(valueStyle, value)
587 data["shallowSize"] = Number.withThousandsSeparator(this._shallowSize); 582 {
588 data["retainedSize"] = Number.withThousandsSeparator(this._retainedSize) ; 583 var cell = document.createElement("td");
589 data["shallowSize-percent"] = this._toPercentString(this._shallowSizePer cent); 584 cell.className = "object-column";
590 data["retainedSize-percent"] = this._toPercentString(this._retainedSizeP ercent); 585 var div = document.createElement("div");
586 div.className = "source-code event-properties";
587 div.style.overflow = "visible";
591 588
592 return this._enhanceData ? this._enhanceData(data) : data; 589 this._prefixObjectCell(div);
590
591 var valueSpan = document.createElement("span");
592 valueSpan.className = "value console-formatted-" + valueStyle;
593 valueSpan.textContent = value;
594 div.appendChild(valueSpan);
595
596 var idSpan = document.createElement("span");
597 idSpan.className = "console-formatted-id";
598 idSpan.textContent = " @" + this.snapshotNodeId;
599 div.appendChild(idSpan);
600
601 cell.appendChild(div);
602 cell.classList.add("disclosure");
603 if (this.depth)
604 cell.style.setProperty("padding-left", (this.depth * this.dataGrid.i ndentWidth) + "px");
605 cell.heapSnapshotNode = this;
606 return cell;
607 },
608
609 _prefixObjectCell: function(div)
610 {
593 }, 611 },
594 612
595 queryObjectContent: function(callback, objectGroupName) 613 queryObjectContent: function(callback, objectGroupName)
596 { 614 {
597 /** 615 /**
598 * @param {?Protocol.Error} error 616 * @param {?Protocol.Error} error
599 * @param {!RuntimeAgent.RemoteObject} object 617 * @param {!RuntimeAgent.RemoteObject} object
600 */ 618 */
601 function formatResult(error, object) 619 function formatResult(error, object)
602 { 620 {
603 if (!error && object.type) 621 if (!error && object.type)
604 callback(WebInspector.RemoteObject.fromPayload(object), !!error) ; 622 callback(WebInspector.RemoteObject.fromPayload(object), !!error) ;
605 else 623 else
606 callback(WebInspector.RemoteObject.fromPrimitiveValue(WebInspect or.UIString("Preview is not available"))); 624 callback(WebInspector.RemoteObject.fromPrimitiveValue(WebInspect or.UIString("Preview is not available")));
607 } 625 }
608 626
609 if (this._type === "string") 627 if (this._type === "string")
610 callback(WebInspector.RemoteObject.fromPrimitiveValue(this._name)); 628 callback(WebInspector.RemoteObject.fromPrimitiveValue(this._name));
611 else 629 else
612 HeapProfilerAgent.getObjectByHeapObjectId(String(this.snapshotNodeId ), objectGroupName, formatResult); 630 HeapProfilerAgent.getObjectByHeapObjectId(String(this.snapshotNodeId ), objectGroupName, formatResult);
613 }, 631 },
614 632
615 get _retainedSizePercent()
616 {
617 return this._retainedSize / this.dataGrid.snapshot.totalSize * 100.0;
618 },
619
620 get _shallowSizePercent()
621 {
622 return this._shallowSize / this.dataGrid.snapshot.totalSize * 100.0;
623 },
624
625 updateHasChildren: function() 633 updateHasChildren: function()
626 { 634 {
627 /** 635 /**
628 * @this {WebInspector.HeapSnapshotGenericObjectNode} 636 * @this {WebInspector.HeapSnapshotGenericObjectNode}
629 */ 637 */
630 function isEmptyCallback(isEmpty) 638 function isEmptyCallback(isEmpty)
631 { 639 {
632 this.hasChildren = !isEmpty; 640 this.hasChildren = !isEmpty;
633 } 641 }
634 this._provider().isEmpty(isEmptyCallback.bind(this)); 642 this._provider().isEmpty(isEmptyCallback.bind(this));
(...skipping 17 matching lines...) Expand all
652 } else 660 } else
653 return fullName; 661 return fullName;
654 }, 662 },
655 663
656 __proto__: WebInspector.HeapSnapshotGridNode.prototype 664 __proto__: WebInspector.HeapSnapshotGridNode.prototype
657 } 665 }
658 666
659 /** 667 /**
660 * @constructor 668 * @constructor
661 * @extends {WebInspector.HeapSnapshotGenericObjectNode} 669 * @extends {WebInspector.HeapSnapshotGenericObjectNode}
662 * @param {!WebInspector.HeapSnapshotSortableDataGrid} tree 670 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid
663 * @param {boolean} isFromBaseSnapshot 671 * @param {!WebInspector.HeapSnapshotProxy} snapshot
664 */ 672 */
665 WebInspector.HeapSnapshotObjectNode = function(tree, isFromBaseSnapshot, edge, p arentGridNode) 673 WebInspector.HeapSnapshotObjectNode = function(dataGrid, snapshot, edge, parentG ridNode)
666 { 674 {
667 WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, edge.node); 675 WebInspector.HeapSnapshotGenericObjectNode.call(this, dataGrid, edge.node);
668 this._referenceName = edge.name; 676 this._referenceName = edge.name;
669 this._referenceType = edge.type; 677 this._referenceType = edge.type;
670 this._distance = edge.distance; 678 this.showRetainingEdges = dataGrid.showRetainingEdges;
671 this.showRetainingEdges = tree.showRetainingEdges; 679 this._snapshot = snapshot;
672 this._isFromBaseSnapshot = isFromBaseSnapshot;
673 680
674 this._parentGridNode = parentGridNode; 681 this._parentGridNode = parentGridNode;
675 this._cycledWithAncestorGridNode = this._findAncestorWithSameSnapshotNodeId( ); 682 this._cycledWithAncestorGridNode = this._findAncestorWithSameSnapshotNodeId( );
676 if (!this._cycledWithAncestorGridNode) 683 if (!this._cycledWithAncestorGridNode)
677 this.updateHasChildren(); 684 this.updateHasChildren();
685
686 var data = this.data;
687 data["count"] = "";
688 data["addedCount"] = "";
689 data["removedCount"] = "";
690 data["countDelta"] = "";
691 data["addedSize"] = "";
692 data["removedSize"] = "";
693 data["sizeDelta"] = "";
678 } 694 }
679 695
680 WebInspector.HeapSnapshotObjectNode.prototype = { 696 WebInspector.HeapSnapshotObjectNode.prototype = {
681 /** 697 /**
698 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:nu mber}}
699 */
700 retainersDataSource: function()
701 {
702 return {snapshot: this._snapshot, snapshotNodeIndex: this.snapshotNodeIn dex};
703 },
704
705 /**
682 * @return {!WebInspector.HeapSnapshotProviderProxy} 706 * @return {!WebInspector.HeapSnapshotProviderProxy}
683 */ 707 */
684 createProvider: function() 708 createProvider: function()
685 { 709 {
686 var tree = this._dataGrid; 710 var tree = this._dataGrid;
687 var showHiddenData = WebInspector.settings.showAdvancedHeapSnapshotPrope rties.get(); 711 var showHiddenData = WebInspector.settings.showAdvancedHeapSnapshotPrope rties.get();
688 var snapshot = this._isFromBaseSnapshot ? tree.baseSnapshot : tree.snaps hot;
689 if (this.showRetainingEdges) 712 if (this.showRetainingEdges)
690 return snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex, showHiddenData); 713 return this._snapshot.createRetainingEdgesProvider(this.snapshotNode Index, showHiddenData);
691 else 714 else
692 return snapshot.createEdgesProvider(this.snapshotNodeIndex, showHidd enData); 715 return this._snapshot.createEdgesProvider(this.snapshotNodeIndex, sh owHiddenData);
693 }, 716 },
694 717
695 _findAncestorWithSameSnapshotNodeId: function() 718 _findAncestorWithSameSnapshotNodeId: function()
696 { 719 {
697 var ancestor = this._parentGridNode; 720 var ancestor = this._parentGridNode;
698 while (ancestor) { 721 while (ancestor) {
699 if (ancestor.snapshotNodeId === this.snapshotNodeId) 722 if (ancestor.snapshotNodeId === this.snapshotNodeId)
700 return ancestor; 723 return ancestor;
701 ancestor = ancestor._parentGridNode; 724 ancestor = ancestor._parentGridNode;
702 } 725 }
703 return null; 726 return null;
704 }, 727 },
705 728
706 _createChildNode: function(item) 729 _createChildNode: function(item)
707 { 730 {
708 return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._isF romBaseSnapshot, item, this); 731 return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._sna pshot, item, this);
709 }, 732 },
710 733
711 _childHashForEntity: function(edge) 734 _childHashForEntity: function(edge)
712 { 735 {
713 var prefix = this.showRetainingEdges ? edge.node.id + "#" : ""; 736 var prefix = this.showRetainingEdges ? edge.node.id + "#" : "";
714 return prefix + edge.type + "#" + edge.name; 737 return prefix + edge.type + "#" + edge.name;
715 }, 738 },
716 739
717 _childHashForNode: function(childNode) 740 _childHashForNode: function(childNode)
718 { 741 {
(...skipping 11 matching lines...) Expand all
730 var sortFields = { 753 var sortFields = {
731 object: ["!edgeName", sortAscending, "retainedSize", false], 754 object: ["!edgeName", sortAscending, "retainedSize", false],
732 count: ["!edgeName", true, "retainedSize", false], 755 count: ["!edgeName", true, "retainedSize", false],
733 shallowSize: ["selfSize", sortAscending, "!edgeName", true], 756 shallowSize: ["selfSize", sortAscending, "!edgeName", true],
734 retainedSize: ["retainedSize", sortAscending, "!edgeName", true], 757 retainedSize: ["retainedSize", sortAscending, "!edgeName", true],
735 distance: ["distance", sortAscending, "_name", true] 758 distance: ["distance", sortAscending, "_name", true]
736 }[sortColumnIdentifier] || ["!edgeName", true, "retainedSize", false]; 759 }[sortColumnIdentifier] || ["!edgeName", true, "retainedSize", false];
737 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 760 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);
738 }, 761 },
739 762
740 _emptyData: function() 763 _prefixObjectCell: function(div)
741 {
742 return { count: "", addedCount: "", removedCount: "", countDelta: "", ad dedSize: "", removedSize: "", sizeDelta: "" };
743 },
744
745 _enhanceData: function(data)
746 { 764 {
747 var name = this._referenceName; 765 var name = this._referenceName;
748 if (name === "") name = "(empty)"; 766 if (name === "") name = "(empty)";
749 var nameClass = "name"; 767 var nameClass = "name";
750 switch (this._referenceType) { 768 switch (this._referenceType) {
751 case "context": 769 case "context":
752 nameClass = "console-formatted-number"; 770 nameClass = "console-formatted-number";
753 break; 771 break;
754 case "internal": 772 case "internal":
755 case "hidden": 773 case "hidden":
756 case "weak": 774 case "weak":
757 nameClass = "console-formatted-null"; 775 nameClass = "console-formatted-null";
758 break; 776 break;
759 case "element": 777 case "element":
760 name = "[" + name + "]"; 778 name = "[" + name + "]";
761 break; 779 break;
762 } 780 }
763 data["object"].nameClass = nameClass;
764 data["object"].name = name;
765 data["distance"] = this._distance;
766 return data;
767 },
768 781
769 _prefixObjectCell: function(div, data)
770 {
771 if (this._cycledWithAncestorGridNode) 782 if (this._cycledWithAncestorGridNode)
772 div.className += " cycled-ancessor-node"; 783 div.className += " cycled-ancessor-node";
773 784
774 var nameSpan = document.createElement("span"); 785 var nameSpan = document.createElement("span");
775 nameSpan.className = data.nameClass; 786 nameSpan.className = nameClass;
776 nameSpan.textContent = data.name; 787 nameSpan.textContent = name;
777 div.appendChild(nameSpan); 788 div.appendChild(nameSpan);
778 789
779 var separatorSpan = document.createElement("span"); 790 var separatorSpan = document.createElement("span");
780 separatorSpan.className = "grayed"; 791 separatorSpan.className = "grayed";
781 separatorSpan.textContent = this.showRetainingEdges ? " in " : " :: "; 792 separatorSpan.textContent = this.showRetainingEdges ? " in " : " :: ";
782 div.appendChild(separatorSpan); 793 div.appendChild(separatorSpan);
783 }, 794 },
784 795
785 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype 796 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype
786 } 797 }
787 798
788 /** 799 /**
789 * @constructor 800 * @constructor
790 * @extends {WebInspector.HeapSnapshotGenericObjectNode} 801 * @extends {WebInspector.HeapSnapshotGenericObjectNode}
802 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid
803 * @param {!WebInspector.HeapSnapshotProxy} snapshot
804 * @param {boolean} isDeletedNode
791 */ 805 */
792 WebInspector.HeapSnapshotInstanceNode = function(tree, baseSnapshot, snapshot, n ode) 806 WebInspector.HeapSnapshotInstanceNode = function(dataGrid, snapshot, node, isDel etedNode)
793 { 807 {
794 WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, node); 808 WebInspector.HeapSnapshotGenericObjectNode.call(this, dataGrid, node);
795 this._baseSnapshotOrSnapshot = baseSnapshot || snapshot; 809 this._baseSnapshotOrSnapshot = snapshot;
796 this._isDeletedNode = !!baseSnapshot; 810 this._isDeletedNode = isDeletedNode;
797 this.updateHasChildren(); 811 this.updateHasChildren();
812
813 var data = this.data;
814 data["count"] = "";
815 data["countDelta"] = "";
816 data["sizeDelta"] = "";
817 if (this._isDeletedNode) {
818 data["addedCount"] = "";
819 data["addedSize"] = "";
820 data["removedCount"] = "\u2022";
821 data["removedSize"] = Number.withThousandsSeparator(this._shallowSize);
822 } else {
823 data["addedCount"] = "\u2022";
824 data["addedSize"] = Number.withThousandsSeparator(this._shallowSize);
825 data["removedCount"] = "";
826 data["removedSize"] = "";
827 }
798 }; 828 };
799 829
800 WebInspector.HeapSnapshotInstanceNode.prototype = { 830 WebInspector.HeapSnapshotInstanceNode.prototype = {
801 /** 831 /**
832 * @return {?{snapshot:!WebInspector.HeapSnapshotProxy, snapshotNodeIndex:nu mber}}
833 */
834 retainersDataSource: function()
835 {
836 return {snapshot: this._baseSnapshotOrSnapshot, snapshotNodeIndex: this. snapshotNodeIndex};
837 },
838
839 /**
802 * @return {!WebInspector.HeapSnapshotProviderProxy} 840 * @return {!WebInspector.HeapSnapshotProviderProxy}
803 */ 841 */
804 createProvider: function() 842 createProvider: function()
805 { 843 {
806 var showHiddenData = WebInspector.settings.showAdvancedHeapSnapshotPrope rties.get(); 844 var showHiddenData = WebInspector.settings.showAdvancedHeapSnapshotPrope rties.get();
807 return this._baseSnapshotOrSnapshot.createEdgesProvider( 845 return this._baseSnapshotOrSnapshot.createEdgesProvider(
808 this.snapshotNodeIndex, 846 this.snapshotNodeIndex,
809 showHiddenData); 847 showHiddenData);
810 }, 848 },
811 849
812 _createChildNode: function(item) 850 _createChildNode: function(item)
813 { 851 {
814 return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._isD eletedNode, item, null); 852 return new WebInspector.HeapSnapshotObjectNode(this._dataGrid, this._bas eSnapshotOrSnapshot, item, null);
815 }, 853 },
816 854
817 _childHashForEntity: function(edge) 855 _childHashForEntity: function(edge)
818 { 856 {
819 return edge.type + "#" + edge.name; 857 return edge.type + "#" + edge.name;
820 }, 858 },
821 859
822 _childHashForNode: function(childNode) 860 _childHashForNode: function(childNode)
823 { 861 {
824 return childNode._referenceType + "#" + childNode._referenceName; 862 return childNode._referenceType + "#" + childNode._referenceName;
(...skipping 11 matching lines...) Expand all
836 distance: ["distance", sortAscending, "retainedSize", false], 874 distance: ["distance", sortAscending, "retainedSize", false],
837 count: ["!edgeName", true, "retainedSize", false], 875 count: ["!edgeName", true, "retainedSize", false],
838 addedSize: ["selfSize", sortAscending, "!edgeName", true], 876 addedSize: ["selfSize", sortAscending, "!edgeName", true],
839 removedSize: ["selfSize", sortAscending, "!edgeName", true], 877 removedSize: ["selfSize", sortAscending, "!edgeName", true],
840 shallowSize: ["selfSize", sortAscending, "!edgeName", true], 878 shallowSize: ["selfSize", sortAscending, "!edgeName", true],
841 retainedSize: ["retainedSize", sortAscending, "!edgeName", true] 879 retainedSize: ["retainedSize", sortAscending, "!edgeName", true]
842 }[sortColumnIdentifier] || ["!edgeName", true, "retainedSize", false]; 880 }[sortColumnIdentifier] || ["!edgeName", true, "retainedSize", false];
843 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 881 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);
844 }, 882 },
845 883
846 _emptyData: function()
847 {
848 return {count: "", countDelta: "", sizeDelta: ""};
849 },
850
851 _enhanceData: function(data)
852 {
853 if (this._isDeletedNode) {
854 data["addedCount"] = "";
855 data["addedSize"] = "";
856 data["removedCount"] = "\u2022";
857 data["removedSize"] = Number.withThousandsSeparator(this._shallowSiz e);
858 } else {
859 data["addedCount"] = "\u2022";
860 data["addedSize"] = Number.withThousandsSeparator(this._shallowSize) ;
861 data["removedCount"] = "";
862 data["removedSize"] = "";
863 }
864 return data;
865 },
866
867 get isDeletedNode()
868 {
869 return this._isDeletedNode;
870 },
871
872 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype 884 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype
873 } 885 }
874 886
875 /** 887 /**
876 * @constructor 888 * @constructor
889 * @param {!WebInspector.HeapSnapshotConstructorsDataGrid} dataGrid
877 * @param {string} className 890 * @param {string} className
878 * @param {!WebInspector.HeapSnapshotCommon.Aggregate} aggregate 891 * @param {!WebInspector.HeapSnapshotCommon.Aggregate} aggregate
879 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter 892 * @param {!WebInspector.HeapSnapshotCommon.NodeFilter} nodeFilter
880 * @extends {WebInspector.HeapSnapshotGridNode} 893 * @extends {WebInspector.HeapSnapshotGridNode}
881 */ 894 */
882 WebInspector.HeapSnapshotConstructorNode = function(tree, className, aggregate, nodeFilter) 895 WebInspector.HeapSnapshotConstructorNode = function(dataGrid, className, aggrega te, nodeFilter)
883 { 896 {
884 WebInspector.HeapSnapshotGridNode.call(this, tree, aggregate.count > 0); 897 WebInspector.HeapSnapshotGridNode.call(this, dataGrid, aggregate.count > 0);
885 this._name = className; 898 this._name = className;
886 this._nodeFilter = nodeFilter; 899 this._nodeFilter = nodeFilter;
887 this._distance = aggregate.distance; 900 this._distance = aggregate.distance;
888 this._count = aggregate.count; 901 this._count = aggregate.count;
889 this._shallowSize = aggregate.self; 902 this._shallowSize = aggregate.self;
890 this._retainedSize = aggregate.maxRet; 903 this._retainedSize = aggregate.maxRet;
loislo 2014/03/26 08:36:04 ditto
yurys 2014/03/26 09:25:09 Same as above.
904
905 var snapshot = dataGrid.snapshot;
906 var countPercent = this._count / snapshot.nodeCount * 100.0;
907 var retainedSizePercent = this._retainedSize / snapshot.totalSize * 100.0;
908 var shallowSizePercent = this._shallowSize / snapshot.totalSize * 100.0;
909
910 this.data = {
911 "object": className,
912 "count": Number.withThousandsSeparator(this._count),
913 "distance": this._distance,
914 "shallowSize": Number.withThousandsSeparator(this._shallowSize),
915 "retainedSize": Number.withThousandsSeparator(this._retainedSize),
916 "count-percent": this._toPercentString(countPercent),
917 "shallowSize-percent": this._toPercentString(shallowSizePercent),
918 "retainedSize-percent": this._toPercentString(retainedSizePercent)
919 };
891 } 920 }
892 921
893 WebInspector.HeapSnapshotConstructorNode.prototype = { 922 WebInspector.HeapSnapshotConstructorNode.prototype = {
894 /** 923 /**
895 * @override 924 * @override
896 * @return {!WebInspector.HeapSnapshotProviderProxy} 925 * @return {!WebInspector.HeapSnapshotProviderProxy}
897 */ 926 */
898 createProvider: function() 927 createProvider: function()
899 { 928 {
900 return this._dataGrid.snapshot.createNodesProviderForClass(this._name, t his._nodeFilter) 929 return this._dataGrid.snapshot.createNodesProviderForClass(this._name, t his._nodeFilter)
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 createCell: function(columnIdentifier) 989 createCell: function(columnIdentifier)
961 { 990 {
962 var cell = columnIdentifier !== "object" ? this._createValueCell(columnI dentifier) : WebInspector.HeapSnapshotGridNode.prototype.createCell.call(this, c olumnIdentifier); 991 var cell = columnIdentifier !== "object" ? this._createValueCell(columnI dentifier) : WebInspector.HeapSnapshotGridNode.prototype.createCell.call(this, c olumnIdentifier);
963 if (this._searchMatched) 992 if (this._searchMatched)
964 cell.classList.add("highlight"); 993 cell.classList.add("highlight");
965 return cell; 994 return cell;
966 }, 995 },
967 996
968 _createChildNode: function(item) 997 _createChildNode: function(item)
969 { 998 {
970 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, null, t his._dataGrid.snapshot, item); 999 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, this._d ataGrid.snapshot, item, false);
971 }, 1000 },
972 1001
973 /** 1002 /**
974 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig} 1003 * @return {!WebInspector.HeapSnapshotCommon.ComparatorConfig}
975 */ 1004 */
976 comparator: function() 1005 comparator: function()
977 { 1006 {
978 var sortAscending = this._dataGrid.isSortOrderAscending(); 1007 var sortAscending = this._dataGrid.isSortOrderAscending();
979 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier(); 1008 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier();
980 var sortFields = { 1009 var sortFields = {
981 object: ["id", sortAscending, "retainedSize", false], 1010 object: ["id", sortAscending, "retainedSize", false],
982 distance: ["distance", sortAscending, "retainedSize", false], 1011 distance: ["distance", sortAscending, "retainedSize", false],
983 count: ["id", true, "retainedSize", false], 1012 count: ["id", true, "retainedSize", false],
984 shallowSize: ["selfSize", sortAscending, "id", true], 1013 shallowSize: ["selfSize", sortAscending, "id", true],
985 retainedSize: ["retainedSize", sortAscending, "id", true] 1014 retainedSize: ["retainedSize", sortAscending, "id", true]
986 }[sortColumnIdentifier]; 1015 }[sortColumnIdentifier];
987 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 1016 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);
988 }, 1017 },
989 1018
990 _childHashForEntity: function(node) 1019 _childHashForEntity: function(node)
991 { 1020 {
992 return node.id; 1021 return node.id;
993 }, 1022 },
994 1023
995 _childHashForNode: function(childNode) 1024 _childHashForNode: function(childNode)
996 { 1025 {
997 return childNode.snapshotNodeId; 1026 return childNode.snapshotNodeId;
998 }, 1027 },
999 1028
1000 get data()
1001 {
1002 var data = { object: this._name };
1003 data["count"] = Number.withThousandsSeparator(this._count);
1004 data["distance"] = this._distance;
1005 data["shallowSize"] = Number.withThousandsSeparator(this._shallowSize);
1006 data["retainedSize"] = Number.withThousandsSeparator(this._retainedSize) ;
1007 data["count-percent"] = this._toPercentString(this._countPercent);
1008 data["shallowSize-percent"] = this._toPercentString(this._shallowSizePer cent);
1009 data["retainedSize-percent"] = this._toPercentString(this._retainedSizeP ercent);
1010 return data;
1011 },
1012
1013 get _countPercent()
1014 {
1015 return this._count / this.dataGrid.snapshot.nodeCount * 100.0;
1016 },
1017
1018 get _retainedSizePercent()
1019 {
1020 return this._retainedSize / this.dataGrid.snapshot.totalSize * 100.0;
1021 },
1022
1023 get _shallowSizePercent()
1024 {
1025 return this._shallowSize / this.dataGrid.snapshot.totalSize * 100.0;
1026 },
1027
1028 __proto__: WebInspector.HeapSnapshotGridNode.prototype 1029 __proto__: WebInspector.HeapSnapshotGridNode.prototype
1029 } 1030 }
1030 1031
1031 1032
1032 /** 1033 /**
1033 * @constructor 1034 * @constructor
1034 * @implements {WebInspector.HeapSnapshotGridNode.ChildrenProvider} 1035 * @implements {WebInspector.HeapSnapshotGridNode.ChildrenProvider}
1035 * @param {!WebInspector.HeapSnapshotProviderProxy} addedNodesProvider 1036 * @param {!WebInspector.HeapSnapshotProviderProxy} addedNodesProvider
1036 * @param {!WebInspector.HeapSnapshotProviderProxy} deletedNodesProvider 1037 * @param {!WebInspector.HeapSnapshotProviderProxy} deletedNodesProvider
1037 */ 1038 */
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 function afterSort() 1140 function afterSort()
1140 { 1141 {
1141 this._deletedNodesProvider.sortAndRewind(comparator, callback); 1142 this._deletedNodesProvider.sortAndRewind(comparator, callback);
1142 } 1143 }
1143 this._addedNodesProvider.sortAndRewind(comparator, afterSort.bind(this)) ; 1144 this._addedNodesProvider.sortAndRewind(comparator, afterSort.bind(this)) ;
1144 } 1145 }
1145 }; 1146 };
1146 1147
1147 /** 1148 /**
1148 * @constructor 1149 * @constructor
1150 * @param {!WebInspector.HeapSnapshotDiffDataGrid} dataGrid
1149 * @param {string} className 1151 * @param {string} className
1150 * @param {!WebInspector.HeapSnapshotCommon.DiffForClass} diffForClass 1152 * @param {!WebInspector.HeapSnapshotCommon.DiffForClass} diffForClass
1151 * @extends {WebInspector.HeapSnapshotGridNode} 1153 * @extends {WebInspector.HeapSnapshotGridNode}
1152 */ 1154 */
1153 WebInspector.HeapSnapshotDiffNode = function(tree, className, diffForClass) 1155 WebInspector.HeapSnapshotDiffNode = function(dataGrid, className, diffForClass)
1154 { 1156 {
1155 WebInspector.HeapSnapshotGridNode.call(this, tree, true); 1157 WebInspector.HeapSnapshotGridNode.call(this, dataGrid, true);
1156 this._name = className; 1158 this._name = className;
1157
1158 this._addedCount = diffForClass.addedCount; 1159 this._addedCount = diffForClass.addedCount;
1159 this._removedCount = diffForClass.removedCount; 1160 this._removedCount = diffForClass.removedCount;
1160 this._countDelta = diffForClass.countDelta; 1161 this._countDelta = diffForClass.countDelta;
loislo 2014/03/26 08:36:04 looks like we don't need _countDelta, _addedSize,
1161 this._addedSize = diffForClass.addedSize; 1162 this._addedSize = diffForClass.addedSize;
1162 this._removedSize = diffForClass.removedSize; 1163 this._removedSize = diffForClass.removedSize;
1163 this._sizeDelta = diffForClass.sizeDelta; 1164 this._sizeDelta = diffForClass.sizeDelta;
1164 this._deletedIndexes = diffForClass.deletedIndexes; 1165 this._deletedIndexes = diffForClass.deletedIndexes;
1166 this.data = {
1167 "object": className,
1168 "addedCount": Number.withThousandsSeparator(this._addedCount),
1169 "removedCount": Number.withThousandsSeparator(this._removedCount),
1170 "countDelta": this._signForDelta(this._countDelta) + Number.withThousan dsSeparator(Math.abs(this._countDelta)),
1171 "addedSize": Number.withThousandsSeparator(this._addedSize),
1172 "removedSize": Number.withThousandsSeparator(this._removedSize),
1173 "sizeDelta": this._signForDelta(this._sizeDelta) + Number.withThousandsS eparator(Math.abs(this._sizeDelta))
1174 };
1165 } 1175 }
1166 1176
1167 WebInspector.HeapSnapshotDiffNode.prototype = { 1177 WebInspector.HeapSnapshotDiffNode.prototype = {
1168 /** 1178 /**
1169 * @override 1179 * @override
1170 * @return {!WebInspector.HeapSnapshotDiffNodesProvider} 1180 * @return {!WebInspector.HeapSnapshotDiffNodesProvider}
1171 */ 1181 */
1172 createProvider: function() 1182 createProvider: function()
1173 { 1183 {
1174 var tree = this._dataGrid; 1184 var tree = this._dataGrid;
1175 return new WebInspector.HeapSnapshotDiffNodesProvider( 1185 return new WebInspector.HeapSnapshotDiffNodesProvider(
1176 tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._ name), 1186 tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid, this._ name),
1177 tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes), 1187 tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes),
1178 this._addedCount, 1188 this._addedCount,
1179 this._removedCount); 1189 this._removedCount);
1180 }, 1190 },
1181 1191
1182 _createChildNode: function(item) 1192 _createChildNode: function(item)
1183 { 1193 {
1184 if (item.isAddedNotRemoved) 1194 if (item.isAddedNotRemoved)
1185 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, nul l, this._dataGrid.snapshot, item); 1195 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.snapshot, item, false);
1186 else 1196 else
1187 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.baseSnapshot, null, item); 1197 return new WebInspector.HeapSnapshotInstanceNode(this._dataGrid, thi s._dataGrid.baseSnapshot, item, true);
1188 }, 1198 },
1189 1199
1190 _childHashForEntity: function(node) 1200 _childHashForEntity: function(node)
1191 { 1201 {
1192 return node.id; 1202 return node.id;
1193 }, 1203 },
1194 1204
1195 _childHashForNode: function(childNode) 1205 _childHashForNode: function(childNode)
1196 { 1206 {
1197 return childNode.snapshotNodeId; 1207 return childNode.snapshotNodeId;
(...skipping 29 matching lines...) Expand all
1227 _signForDelta: function(delta) 1237 _signForDelta: function(delta)
1228 { 1238 {
1229 if (delta === 0) 1239 if (delta === 0)
1230 return ""; 1240 return "";
1231 if (delta > 0) 1241 if (delta > 0)
1232 return "+"; 1242 return "+";
1233 else 1243 else
1234 return "\u2212"; // Math minus sign, same width as plus. 1244 return "\u2212"; // Math minus sign, same width as plus.
1235 }, 1245 },
1236 1246
1237 get data()
1238 {
1239 var data = {object: this._name};
1240
1241 data["addedCount"] = Number.withThousandsSeparator(this._addedCount);
1242 data["removedCount"] = Number.withThousandsSeparator(this._removedCount) ;
1243 data["countDelta"] = this._signForDelta(this._countDelta) + Number.withT housandsSeparator(Math.abs(this._countDelta));
1244 data["addedSize"] = Number.withThousandsSeparator(this._addedSize);
1245 data["removedSize"] = Number.withThousandsSeparator(this._removedSize);
1246 data["sizeDelta"] = this._signForDelta(this._sizeDelta) + Number.withTho usandsSeparator(Math.abs(this._sizeDelta));
1247
1248 return data;
1249 },
1250
1251 __proto__: WebInspector.HeapSnapshotGridNode.prototype 1247 __proto__: WebInspector.HeapSnapshotGridNode.prototype
1252 } 1248 }
1253 1249
1254 1250
1255 /** 1251 /**
1256 * @constructor 1252 * @constructor
1257 * @extends {WebInspector.HeapSnapshotGenericObjectNode} 1253 * @extends {WebInspector.HeapSnapshotGenericObjectNode}
1254 * @param {!WebInspector.HeapSnapshotSortableDataGrid} dataGrid
1258 */ 1255 */
1259 WebInspector.HeapSnapshotDominatorObjectNode = function(tree, node) 1256 WebInspector.HeapSnapshotDominatorObjectNode = function(dataGrid, node)
1260 { 1257 {
1261 WebInspector.HeapSnapshotGenericObjectNode.call(this, tree, node); 1258 WebInspector.HeapSnapshotGenericObjectNode.call(this, dataGrid, node);
1262 this.updateHasChildren(); 1259 this.updateHasChildren();
1263 }; 1260 };
1264 1261
1265 WebInspector.HeapSnapshotDominatorObjectNode.prototype = { 1262 WebInspector.HeapSnapshotDominatorObjectNode.prototype = {
1266 /** 1263 /**
1267 * @override 1264 * @override
1268 * @return {!WebInspector.HeapSnapshotProviderProxy} 1265 * @return {!WebInspector.HeapSnapshotProviderProxy}
1269 */ 1266 */
1270 createProvider: function() 1267 createProvider: function()
1271 { 1268 {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 var sortAscending = this._dataGrid.isSortOrderAscending(); 1333 var sortAscending = this._dataGrid.isSortOrderAscending();
1337 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier(); 1334 var sortColumnIdentifier = this._dataGrid.sortColumnIdentifier();
1338 var sortFields = { 1335 var sortFields = {
1339 object: ["id", sortAscending, "retainedSize", false], 1336 object: ["id", sortAscending, "retainedSize", false],
1340 shallowSize: ["selfSize", sortAscending, "id", true], 1337 shallowSize: ["selfSize", sortAscending, "id", true],
1341 retainedSize: ["retainedSize", sortAscending, "id", true] 1338 retainedSize: ["retainedSize", sortAscending, "id", true]
1342 }[sortColumnIdentifier]; 1339 }[sortColumnIdentifier];
1343 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields); 1340 return WebInspector.HeapSnapshotGridNode.createComparator(sortFields);
1344 }, 1341 },
1345 1342
1346 _emptyData: function()
1347 {
1348 return {};
1349 },
1350
1351 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype 1343 __proto__: WebInspector.HeapSnapshotGenericObjectNode.prototype
1352 } 1344 }
1353 1345
1354 1346
1355 /** 1347 /**
1356 * @constructor 1348 * @constructor
1357 * @extends {WebInspector.DataGridNode} 1349 * @extends {WebInspector.DataGridNode}
1358 * @param {!WebInspector.AllocationDataGrid} dataGrid 1350 * @param {!WebInspector.AllocationDataGrid} dataGrid
1359 * @param {!WebInspector.HeapSnapshotCommon.SerializedAllocationNode} data 1351 * @param {!WebInspector.HeapSnapshotCommon.SerializedAllocationNode} data
1360 */ 1352 */
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 /** 1424 /**
1433 * @return {number} 1425 * @return {number}
1434 */ 1426 */
1435 allocationNodeId: function() 1427 allocationNodeId: function()
1436 { 1428 {
1437 return this.data.id; 1429 return this.data.id;
1438 }, 1430 },
1439 1431
1440 __proto__: WebInspector.DataGridNode.prototype 1432 __proto__: WebInspector.DataGridNode.prototype
1441 } 1433 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/HeapSnapshotDataGrids.js ('k') | Source/devtools/front_end/HeapSnapshotProxy.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698