Web Inspector: Elements: Styles: add icons for various CSS rule types
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Views / HeapSnapshotClassDataGridNode.js
index 0b27de4..5791ac1 100644 (file)
@@ -23,7 +23,7 @@
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-WebInspector.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode extends WebInspector.DataGridNode
+WI.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode extends WI.DataGridNode
 {
     constructor(data, tree)
     {
@@ -44,23 +44,27 @@ WebInspector.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode
 
     createCellContent(columnIdentifier)
     {
-        if (columnIdentifier === "size") {
-            let {size, percent} = this._data;
+        if (columnIdentifier === "retainedSize") {
+            let size = this._data.retainedSize;
             let fragment = document.createDocumentFragment();
-            let timeElement = fragment.appendChild(document.createElement("span"));
-            timeElement.classList.add("size");
-            timeElement.textContent = Number.bytesToString(size);
+            let sizeElement = fragment.appendChild(document.createElement("span"));
+            sizeElement.classList.add("size");
+            sizeElement.textContent = Number.bytesToString(size);
             let percentElement = fragment.appendChild(document.createElement("span"));
             percentElement.classList.add("percentage");
-            percentElement.textContent = Number.percentageString(percent);
+            percentElement.textContent = emDash;
             return fragment;
         }
 
+        if (columnIdentifier === "size")
+            return Number.bytesToString(this._data.size);
+
         if (columnIdentifier === "className") {
-            let {className, allInternal} = this._data;
+            const internal = false;
+            let {className, isObjectSubcategory} = this._data;
             let fragment = document.createDocumentFragment();
             let iconElement = fragment.appendChild(document.createElement("img"));
-            iconElement.classList.add("icon", WebInspector.HeapSnapshotClusterContentView.iconStyleClassNameForClassName(className, allInternal));
+            iconElement.classList.add("icon", WI.HeapSnapshotClusterContentView.iconStyleClassNameForClassName(className, internal, isObjectSubcategory));
             let nameElement = fragment.appendChild(document.createElement("span"));
             nameElement.classList.add("class-name");
             nameElement.textContent = className;
@@ -74,7 +78,7 @@ WebInspector.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode
     {
         if (this._batched) {
             this._removeFetchMoreDataGridNode();
-            this._updateBatchedSort();
+            this._sortInstances();
             this._updateBatchedChildren();
             this._appendFetchMoreDataGridNode();
             return;
@@ -89,31 +93,64 @@ WebInspector.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode
         }
     }
 
+    removeCollectedNodes(collectedNodes)
+    {
+        let nodesToRemove = [];
+
+        this.forEachImmediateChild((dataGridNode) => {
+            if (dataGridNode instanceof WI.HeapSnapshotInstanceDataGridNode) {
+                let heapSnapshotNode = dataGridNode.node;
+                if (heapSnapshotNode.id in collectedNodes)
+                    nodesToRemove.push(dataGridNode);
+            }
+        });
+
+        if (nodesToRemove.length) {
+            for (let dataGridNode of nodesToRemove)
+                this.removeChild(dataGridNode);
+        }
+
+        if (this._instances) {
+            this._instances = this._instances.filter((instance) => !(instance.id in collectedNodes));
+            this._fetchBatch(nodesToRemove.length);
+        }
+    }
+
+    updateCount(count)
+    {
+        if (count === this._data.count)
+            return;
+
+        if (!count) {
+            this._tree.removeChild(this);
+            return;
+        }
+
+        this._data.count = count;
+        this.needsRefresh();
+    }
+
     // Private
 
     _populate()
     {
         this.removeEventListener("populate", this._populate, this);
 
-        let instances = this._tree.heapSnapshot.instancesWithClassName(this._data.className);
+        this._tree.heapSnapshot.instancesWithClassName(this._data.className, (instances) => {
+            // FIXME: <https://webkit.org/b/157905> Web Inspector: Provide a way to toggle between showing only live objects and live+dead objects
+            this._instances = instances.filter((instance) => !instance.dead);
+            this._sortInstances();
 
-        // Batch.
-        if (instances.length > WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit) {
-            // FIXME: This should respect the this._tree.includeInternalObjects setting.
-            this._instances = instances;
-            this._batched = true;
-            this._updateBatchedSort();
-            this._fetchBatch(WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit);
-            return;
-        }
+            // Batch.
+            if (instances.length > WI.HeapSnapshotClassDataGridNode.ChildrenBatchLimit) {
+                this._batched = true;
+                this._fetchBatch(WI.HeapSnapshotClassDataGridNode.ChildrenBatchLimit);
+                return;
+            }
 
-        for (let instance of instances) {
-            if (instance.internal && !this._tree.includeInternalObjects)
-                continue;
-            this.appendChild(new WebInspector.HeapSnapshotInstanceDataGridNode(instance, this._tree));
-        }
-
-        this.sort();
+            for (let instance of this._instances)
+                this.appendChild(new WI.HeapSnapshotInstanceDataGridNode(instance, this._tree));
+        });
     }
 
     _fetchBatch(batchSize)
@@ -130,16 +167,18 @@ WebInspector.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode
         }
 
         let count = newCount - oldCount;
-        for (let i = 0; i <= count; ++i) {
-            let instance = this._instances[oldCount + i];
-            this.appendChild(new WebInspector.HeapSnapshotInstanceDataGridNode(instance, this._tree));
+        if (count) {
+            for (let i = 0; i <= count; ++i) {
+                let instance = this._instances[oldCount + i];
+                this.appendChild(new WI.HeapSnapshotInstanceDataGridNode(instance, this._tree));
+            }
         }
 
         if (this._batched)
             this._appendFetchMoreDataGridNode();
     }
 
-    _updateBatchedSort()
+    _sortInstances()
     {
         this._instances.sort((a, b) => {
             let fakeDataGridNodeA = {data: a};
@@ -155,27 +194,27 @@ WebInspector.HeapSnapshotClassDataGridNode = class HeapSnapshotClassDataGridNode
         this.removeChildren();
 
         for (let i = 0; i < count; ++i)
-            this.appendChild(new WebInspector.HeapSnapshotInstanceDataGridNode(this._instances[i], this._tree));
+            this.appendChild(new WI.HeapSnapshotInstanceDataGridNode(this._instances[i], this._tree));
     }
 
     _removeFetchMoreDataGridNode()
     {
-        console.assert(this.children[this.children.length - 1] instanceof WebInspector.HeapSnapshotInstanceFetchMoreDataGridNode);
+        console.assert(this.children[this.children.length - 1] instanceof WI.HeapSnapshotInstanceFetchMoreDataGridNode);
 
         this.removeChild(this.children[this.children.length - 1]);
     }
 
     _appendFetchMoreDataGridNode()
     {
-        console.assert(!(this.children[this.children.length - 1] instanceof WebInspector.HeapSnapshotInstanceFetchMoreDataGridNode));
+        console.assert(!(this.children[this.children.length - 1] instanceof WI.HeapSnapshotInstanceFetchMoreDataGridNode));
 
         let count = this.children.length;
         let totalCount = this._instances.length;
         let remainingCount = totalCount - count;
-        let batchSize = remainingCount >= WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit ? WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit : 0;
+        let batchSize = remainingCount >= WI.HeapSnapshotClassDataGridNode.ChildrenBatchLimit ? WI.HeapSnapshotClassDataGridNode.ChildrenBatchLimit : 0;
 
-        this.appendChild(new WebInspector.HeapSnapshotInstanceFetchMoreDataGridNode(this._tree, batchSize, remainingCount, this._fetchBatch.bind(this)));
+        this.appendChild(new WI.HeapSnapshotInstanceFetchMoreDataGridNode(this._tree, batchSize, remainingCount, this._fetchBatch.bind(this)));
     }
 };
 
-WebInspector.HeapSnapshotClassDataGridNode.ChildrenBatchLimit = 100;
+WI.HeapSnapshotClassDataGridNode.ChildrenBatchLimit = 100;