Web Inspector: Improve ES6 Class instances in Heap Snapshot instances view
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / HeapSnapshotDataGridTree.js
index 7057f4c..5d725a6 100644 (file)
@@ -216,7 +216,8 @@ WebInspector.HeapSnapshotInstancesDataGridTree = class HeapSnapshotInstancesData
     populateTopLevel()
     {
         // Populate the first level with the different non-internal classes.
-        for (let [className, {size, retainedSize, count, internalCount, deadCount}] of this.heapSnapshot.categories) {
+        for (let [className, {size, retainedSize, count, internalCount, deadCount, objectCount}] of this.heapSnapshot.categories) {
+            console.assert(count > 0);
             if (count === internalCount)
                 continue;
 
@@ -225,7 +226,11 @@ WebInspector.HeapSnapshotInstancesDataGridTree = class HeapSnapshotInstancesData
             if (!liveCount)
                 continue;
 
-            this.appendChild(new WebInspector.HeapSnapshotClassDataGridNode({className, size, retainedSize, count: liveCount}, this));
+            // If over half of the objects with this class name are Object sub-types, treat this as an Object category.
+            // This can happen if the page has a JavaScript Class with the same name as a native class.
+            let isObjectSubcategory = (objectCount / count) > 0.5;
+
+            this.appendChild(new WebInspector.HeapSnapshotClassDataGridNode({className, size, retainedSize, isObjectSubcategory, count: liveCount}, this));
         }
 
         this.didPopulate();