Web Inspector: DetailedHeapSnapshot: Replace the list of retainers with the expandabl...
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 09:23:48 +0000 (09:23 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 23 Jan 2012 09:23:48 +0000 (09:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76813

Reviewed by Pavel Feldman.

* English.lproj/localizedStrings.js:
* inspector/front-end/DetailedHeapshotGridNodes.js:
(WebInspector.HeapSnapshotObjectNode):
* inspector/front-end/DetailedHeapshotView.js:
(WebInspector.HeapSnapshotContainmentDataGrid.prototype.setDataSource):
(WebInspector.HeapSnapshotRetainmentDataGrid):
(WebInspector.HeapSnapshotRetainmentDataGrid.prototype.reset):
(WebInspector.DetailedHeapshotView.prototype._startRetainersHeaderDragging):
* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshot.prototype.createRetainingEdgesProvider):
(WebInspector.HeapSnapshotEdgesProvider):
* inspector/front-end/HeapSnapshotProxy.js:
(WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
(WebInspector.HeapSnapshotProxy.prototype.createRetainingEdgesProvider):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@105598 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/English.lproj/localizedStrings.js
Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js
Source/WebCore/inspector/front-end/DetailedHeapshotView.js
Source/WebCore/inspector/front-end/HeapSnapshot.js
Source/WebCore/inspector/front-end/HeapSnapshotProxy.js

index 1896cb114bbe62a739c5ca118055cf8d6c48d2ff..71db8e4c5ef54772ad47853b0955a7527ffb7675 100644 (file)
@@ -1,3 +1,25 @@
+2012-01-23  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Web Inspector: DetailedHeapSnapshot: Replace the list of retainers with the expandable tree (to get rid of cycles)
+        https://bugs.webkit.org/show_bug.cgi?id=76813
+
+        Reviewed by Pavel Feldman.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/DetailedHeapshotGridNodes.js:
+        (WebInspector.HeapSnapshotObjectNode):
+        * inspector/front-end/DetailedHeapshotView.js:
+        (WebInspector.HeapSnapshotContainmentDataGrid.prototype.setDataSource):
+        (WebInspector.HeapSnapshotRetainmentDataGrid):
+        (WebInspector.HeapSnapshotRetainmentDataGrid.prototype.reset):
+        (WebInspector.DetailedHeapshotView.prototype._startRetainersHeaderDragging):
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshot.prototype.createRetainingEdgesProvider):
+        (WebInspector.HeapSnapshotEdgesProvider):
+        * inspector/front-end/HeapSnapshotProxy.js:
+        (WebInspector.HeapSnapshotProxy.prototype.createEdgesProvider):
+        (WebInspector.HeapSnapshotProxy.prototype.createRetainingEdgesProvider):
+
 2012-01-20  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: HAR pageref attributes are wrong and inconsistent with pages array
index 48f9132bf6de6b69979fba2160dea2395778ce87..5c584f4d8a456f01d309bcef7bb4582ef1599af6 100644 (file)
Binary files a/Source/WebCore/English.lproj/localizedStrings.js and b/Source/WebCore/English.lproj/localizedStrings.js differ
index e05291814406a4764346f092adff6246c9b01321..58530c2c761120f17fb30ed9dedd1a23df8cce25 100644 (file)
@@ -110,7 +110,7 @@ WebInspector.HeapSnapshotGridNode.prototype = {
                         continue;
                     }
                 }
-                this.insertChild(this._createChildNode(item, provider), atIndex++);
+                this.insertChild(this._createChildNode(item, provider, this), atIndex++);
             }
             provider.instanceCount += items.length;
             if (part < howMany) {
@@ -335,7 +335,7 @@ WebInspector.HeapSnapshotObjectNode = function(tree, isFromBaseSnapshot, edge)
     this._referenceName = edge.name;
     this._referenceType = edge.type;
     this._isFromBaseSnapshot = isFromBaseSnapshot;
-    this._provider = this._createProvider(!isFromBaseSnapshot ? tree.snapshot : tree.baseSnapshot, edge.nodeIndex);
+    this._provider = this._createProvider(!isFromBaseSnapshot ? tree.snapshot : tree.baseSnapshot, edge.nodeIndex, tree);
     this._updateHasChildren();
 }
 
@@ -345,15 +345,17 @@ WebInspector.HeapSnapshotObjectNode.prototype = {
         return new WebInspector.HeapSnapshotObjectNode(this.dataGrid, this._isFromBaseSnapshot, item);
     },
 
-    _createProvider: function(snapshot, nodeIndex)
+    _createProvider: function(snapshot, nodeIndex, tree)
     {
         var showHiddenData = WebInspector.settings.showHeapSnapshotObjectsHiddenProperties.get();
-        return snapshot.createEdgesProvider(
-            nodeIndex,
-            "function(edge) {" +
+        var filter = "function(edge) {" +
             "    return !edge.isInvisible" +
             "        && (" + showHiddenData + " || (!edge.isHidden && !edge.node.isHidden));" +
-            "}");
+            "}";
+        if (tree.showRetainingEdges)
+            return snapshot.createRetainingEdgesProvider(nodeIndex, filter);
+        else
+            return snapshot.createEdgesProvider(nodeIndex, filter);
     },
 
     _childHashForEntity: function(edge)
index 7f999d963774c286e3e2325a0cb06377c8b43121..a8869dae27e8914a04680328e7ec7e6c6fd00cee 100644 (file)
@@ -162,12 +162,12 @@ WebInspector.HeapSnapshotContainmentDataGrid.prototype = {
         nextStep(this, 0);
     },
 
-    setDataSource: function(snapshotView, snapshot)
+    setDataSource: function(snapshotView, snapshot, nodeIndex)
     {
         this.snapshotView = snapshotView;
         this.snapshot = snapshot;
-        this.snapshotNodeIndex = this.snapshot.rootNodeIndex;
-        this._provider = this._createProvider(snapshot, this.snapshotNodeIndex);
+        this.snapshotNodeIndex = nodeIndex || this.snapshot.rootNodeIndex;
+        this._provider = this._createProvider(snapshot, this.snapshotNodeIndex, this);
         this.sort();
     },
 
@@ -180,6 +180,22 @@ WebInspector.HeapSnapshotContainmentDataGrid.prototype = {
 MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotObjectNode.prototype, WebInspector.HeapSnapshotContainmentDataGrid.prototype);
 WebInspector.HeapSnapshotContainmentDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
 
+WebInspector.HeapSnapshotRetainmentDataGrid = function()
+{
+    this.showRetainingEdges = true;
+    WebInspector.HeapSnapshotContainmentDataGrid.call(this);
+}
+
+WebInspector.HeapSnapshotRetainmentDataGrid.prototype = {
+    reset: function()
+    {
+        this.removeChildren();
+        this.resetSortingCache();
+    },
+}
+
+WebInspector.HeapSnapshotRetainmentDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotContainmentDataGrid.prototype;
+
 WebInspector.HeapSnapshotConstructorsDataGrid = function()
 {
     var columns = {
@@ -392,176 +408,6 @@ WebInspector.HeapSnapshotDominatorsDataGrid.prototype = {
 MixInSnapshotNodeFunctions(WebInspector.HeapSnapshotDominatorObjectNode.prototype, WebInspector.HeapSnapshotDominatorsDataGrid.prototype);
 WebInspector.HeapSnapshotDominatorsDataGrid.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
 
-WebInspector.HeapSnapshotPathFinderState = function(snapshot, nodeIndex, rootFilter)
-{
-    this._pathFinder = snapshot.createPathFinder(nodeIndex, !WebInspector.settings.showHeapSnapshotObjectsHiddenProperties.get());
-    this._pathFinder.updateRoots(rootFilter);
-    this._foundCount = 0;
-    this._foundCountMax = null;
-    this._totalFoundCount = 0;
-    this._cancelled = false;
-}
-
-WebInspector.HeapSnapshotPathFinderState.prototype = {
-    batchDone: function(status)
-    {
-    },
-
-    pathFound: function(path)
-    {
-    },
-
-    cancel: function()
-    {
-        this._cancelled = true;
-        this._pathFinder.dispose();
-    },
-
-    startBatch: function(count)
-    {
-        if (this._cancelled)
-            return;
-        this._foundCount = 0;
-        this._foundCountMax = count;
-        this._pathFinder.findNext(this._pathFound.bind(this));
-    },
-
-    _pathFound: function(result)
-    {
-        if (this._cancelled)
-            return;
-        if (result === null) {
-            if (!this._totalFoundCount)
-                this.batchDone("no-paths-at-all");
-        } else if (result !== false) {
-            this.pathFound(result);
-            ++this._foundCount;
-            ++this._totalFoundCount;
-            if (this._foundCount < this._foundCountMax)
-                this._pathFinder.findNext(this._pathFound.bind(this));
-            else
-                this.batchDone("have-more-paths");
-        } else {
-            this.batchDone("no-more-paths");
-        }
-    }
-};
-
-WebInspector.HeapSnapshotRetainingPathsList = function()
-{
-    var columns = {
-        path: { title: WebInspector.UIString("Retaining path"), sortable: true },
-        len: { title: WebInspector.UIString("Length"), width: "90px", sortable: true, sort: "ascending" }
-    };
-    WebInspector.HeapSnapshotSortableDataGrid.call(this, columns);
-    this._defaultPopulateCount = 100;
-    this._nodeIndex = null;
-    this._state = null;
-    this._prefix = null;
-}
-
-WebInspector.HeapSnapshotRetainingPathsList.prototype = {
-    dispose: function()
-    {
-        if (this._state)
-            this._state.cancel();
-    },
-
-    _sortFields: function(sortColumn, sortAscending)
-    {
-        return {
-            path: ["path", sortAscending, "len", true],
-            len: ["len", sortAscending, "path", true]
-        }[sortColumn];
-    },
-
-    _resetPaths: function()
-    {
-        var rootFilter = this.snapshotView.isTracingToWindowObjects ?
-            "function (node) { return node.name.substr(0, 9) === \"DOMWindow\"; }" : null;
-        if (this._state)
-            this._state.cancel();
-        this._state = new WebInspector.HeapSnapshotPathFinderState(this._snapshot, this._nodeIndex, rootFilter);
-        this._state.batchDone = this._batchDone.bind(this);
-        this._state.pathFound = this._pathFound.bind(this);
-        this.removeChildren();
-        this.resetSortingCache();
-        this.showNext(this._defaultPopulateCount);
-    },
-
-    setDataSource: function(snapshotView, snapshot, nodeIndex, prefix)
-    {
-        if (this._nodeIndex === nodeIndex)
-            return;
-        this.snapshotView = snapshotView;
-        this._snapshot = snapshot;
-        this._nodeIndex = nodeIndex;
-        this._prefix = prefix;
-        this._resetPaths();
-    },
-
-    refresh: function()
-    {
-        if (this.snapshotView)
-            this._resetPaths();
-    },
-
-    reset: function()
-    {
-        if (this._state)
-            this._state.cancel();
-        this.removeChildren();
-        this.resetSortingCache();
-        this.appendChild(new WebInspector.DataGridNode({path:WebInspector.UIString("Click on an object to show retaining paths"), len:""}, false));
-    },
-
-    _batchDone: function(state)
-    {
-        switch (state) {
-        case "no-paths-at-all":
-            this.appendChild(new WebInspector.DataGridNode({path:WebInspector.UIString("Can't find any paths."), len:""}, false));
-            break;
-        case "have-more-paths":
-            this.appendChild(new WebInspector.ShowMoreDataGridNode(this.showNext.bind(this), this._defaultPopulateCount));
-            this.resetSortingCache();
-            this.sortingChanged();
-            break;
-        case "no-more-paths":
-            // Nothing to do.
-            break;
-        }
-    },
-
-    _pathFound: function(result)
-    {
-        if (WebInspector.HeapSnapshotGenericObjectNode.prototype.isDOMWindow(result.path))
-            result.path = WebInspector.HeapSnapshotGenericObjectNode.prototype.shortenWindowURL(result.path, true);
-        if (this._prefix)
-            result.path = this._prefix + result.path;
-        var node = new WebInspector.DataGridNode(result, false);
-        node.route = result.route;
-        this.appendChild(node);
-    },
-
-    showNext: function(pathsCount)
-    {
-        this._state.startBatch(pathsCount);
-    },
-
-    _performSorting: function(sortFunction)
-    {
-        function DataExtractorWrapper(nodeA, nodeB)
-        {
-            return sortFunction(nodeA.data, nodeB.data);
-        }
-        this.recursiveSortingEnter();
-        this.sortNodes(DataExtractorWrapper);
-        this.recursiveSortingLeave();
-    }
-};
-
-WebInspector.HeapSnapshotRetainingPathsList.prototype.__proto__ = WebInspector.HeapSnapshotSortableDataGrid.prototype;
-
 WebInspector.DetailedHeapshotView = function(parent, profile)
 {
     WebInspector.View.call(this);
@@ -613,25 +459,15 @@ WebInspector.DetailedHeapshotView = function(parent, profile)
     var retainingPathsTitleDiv = document.createElement("div");
     retainingPathsTitleDiv.className = "title";
     var retainingPathsTitle = document.createElement("span");
-    retainingPathsTitle.textContent = WebInspector.UIString("Paths from the selected object");
-    this.retainingPathsRoot = document.createElement("select");
-    this.retainingPathsRoot.className = "status-bar-item";
-    this.retainingPathsRoot.addEventListener("change", this._changeRetainingPathsRoot.bind(this), false);
-    var toGCRootsTraceOption = document.createElement("option");
-    toGCRootsTraceOption.label = WebInspector.UIString("to GC roots");
-    var toWindowObjectsTraceOption = document.createElement("option");
-    toWindowObjectsTraceOption.label = WebInspector.UIString("to window objects");
-    this.retainingPathsRoot.appendChild(toWindowObjectsTraceOption);
-    this.retainingPathsRoot.appendChild(toGCRootsTraceOption);
+    retainingPathsTitle.textContent = WebInspector.UIString("Object's retaining tree");
     retainingPathsTitleDiv.appendChild(retainingPathsTitle);
-    retainingPathsTitleDiv.appendChild(this.retainingPathsRoot);
     this.retainmentViewHeader.appendChild(retainingPathsTitleDiv);
     this.element.appendChild(this.retainmentViewHeader);
 
     this.retainmentView = new WebInspector.View();
     this.retainmentView.element.addStyleClass("view");
     this.retainmentView.element.addStyleClass("retaining-paths-view");
-    this.retainmentDataGrid = new WebInspector.HeapSnapshotRetainingPathsList();
+    this.retainmentDataGrid = new WebInspector.HeapSnapshotRetainmentDataGrid();
     this.retainmentDataGrid.element.addEventListener("click", this._mouseClickInRetainmentGrid.bind(this), true);
     this.retainmentDataGrid.show(this.retainmentView.element);
     this.retainmentView.show(this.element);
@@ -1093,13 +929,6 @@ WebInspector.DetailedHeapshotView.prototype = {
         this.performSearch(this.currentQuery, this._searchFinishedCallback);
     },
 
-    _changeRetainingPathsRoot: function(event)
-    {
-        if (!event)
-            return;
-        this.retainmentDataGrid.refresh();
-    },
-
     _getHoverAnchor: function(target)
     {
         var span = target.enclosingNodeOrSelfWithNodeName("span");
@@ -1115,11 +944,6 @@ WebInspector.DetailedHeapshotView.prototype = {
         return span;
     },
 
-    get isTracingToWindowObjects()
-    {
-        return this.retainingPathsRoot.selectedIndex === 0;
-    },
-
     get _isShowingAsPercent()
     {
         return this.showCountAsPercent && this.showShallowSizeAsPercent && this.showRetainedSizeAsPercent;
@@ -1202,7 +1026,7 @@ WebInspector.DetailedHeapshotView.prototype = {
 
     _startRetainersHeaderDragging: function(event)
     {
-        if (!this.isShowing() || event.target === this.retainingPathsRoot)
+        if (!this.isShowing())
             return;
 
         WebInspector.elementDragStart(this.retainmentViewHeader, this._retainersHeaderDragging.bind(this), this._endRetainersHeaderDragging.bind(this), event, "row-resize");
index a44d4ca9fdb83daa8cb2f4d03972b41bdb0f2ed2..8b1a71924b8f7cd2e8d661ca90a138e79c65f445 100644 (file)
@@ -1148,6 +1148,12 @@ WebInspector.HeapSnapshot.prototype = {
         return new WebInspector.HeapSnapshotEdgesProvider(this, nodeIndex, this._parseFilter(filter));
     },
 
+    createRetainingEdgesProvider: function(nodeIndex, filter)
+    {
+        var node = new WebInspector.HeapSnapshotNode(this, nodeIndex);
+        return new WebInspector.HeapSnapshotEdgesProvider(this, nodeIndex, this._parseFilter(filter), node.retainers);
+    },
+
     createNodesProvider: function(filter)
     {
         return new WebInspector.HeapSnapshotNodesProvider(this, this._parseFilter(filter));
@@ -1301,11 +1307,12 @@ WebInspector.HeapSnapshotFilteredOrderedIterator.prototype.createComparator = fu
     return {fieldName1:fieldNames[0], ascending1:fieldNames[1], fieldName2:fieldNames[2], ascending2:fieldNames[3]};
 }
 
-WebInspector.HeapSnapshotEdgesProvider = function(snapshot, nodeIndex, filter)
+WebInspector.HeapSnapshotEdgesProvider = function(snapshot, nodeIndex, filter, iter)
 {
     this.snapshot = snapshot;
     var node = new WebInspector.HeapSnapshotNode(snapshot, nodeIndex);
-    WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(snapshot, node.rawEdges)), filter);
+    var edgesIter = iter || new WebInspector.HeapSnapshotEdgeIterator(new WebInspector.HeapSnapshotEdge(snapshot, node.rawEdges));
+    WebInspector.HeapSnapshotFilteredOrderedIterator.call(this, edgesIter, filter);
 }
 
 WebInspector.HeapSnapshotEdgesProvider.prototype = {
index 143aaaaa734b84432aa420bb4ad79c7c999b3bb4..2b2823a0d60f3cab3ac7f12d9bc2200e250a62d9 100644 (file)
@@ -325,6 +325,11 @@ WebInspector.HeapSnapshotProxy.prototype = {
         return this.callFactoryMethod(null, "createEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, filter);
     },
 
+    createRetainingEdgesProvider: function(nodeIndex, filter)
+    {
+        return this.callFactoryMethod(null, "createRetainingEdgesProvider", "WebInspector.HeapSnapshotProviderProxy", nodeIndex, filter);
+    },
+
     createNodesProvider: function(filter)
     {
         return this.callFactoryMethod(null, "createNodesProvider", "WebInspector.HeapSnapshotProviderProxy", filter);