Web Inspector: allow showing selected object in another heap profiler view
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 09:53:45 +0000 (09:53 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 09:53:45 +0000 (09:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87098

Reviewed by Vsevolod Vlasov.

Added 2 context menu actions: 1) to jump from a node in the heap snapshot summary
view to the same node in the dominators view; 2) to jump from a node in the dominators
view to the same node in the summary view.

* inspector/front-end/HeapSnapshotDataGrids.js:
(WebInspector.HeapSnapshotSortableDataGrid): "sorting complete" event is only dispatched on
when the data grid is populated. If we switch to already populated data grid the event is not
dispatched. However when switching between different views of a heap snapshot we want to track
the moment when the data grid is shown and populated. I added
WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown for such cases. The event will always
be dispatched after the data grid is shown and its content is populated.
(WebInspector.HeapSnapshotSortableDataGrid.prototype.wasShown):
(WebInspector.HeapSnapshotSortableDataGrid.prototype._sortingComplete):
(WebInspector.HeapSnapshotSortableDataGrid.prototype.populateContextMenu.revealInDominatorsView):
(WebInspector.HeapSnapshotSortableDataGrid.prototype.populateContextMenu.else.revealInSummaryView):
(WebInspector.HeapSnapshotSortableDataGrid.prototype.populateContextMenu):
(WebInspector.HeapSnapshotSortableDataGrid.prototype._performSorting):
* inspector/front-end/HeapSnapshotGridNodes.js:
(WebInspector.HeapSnapshotGenericObjectNode.prototype._createObjectCell):
(WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId):
* inspector/front-end/HeapSnapshotView.js:
(WebInspector.HeapSnapshotView.prototype.populateContextMenu):
(WebInspector.HeapSnapshotView.prototype.changeView.dataGridContentShown):
(WebInspector.HeapSnapshotView.prototype.changeView):
(WebInspector.HeapSnapshotView.prototype._onSelectedViewChanged):
(WebInspector.HeapSnapshotView.prototype._changeView):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel.prototype._handleContextMenuEvent):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/HeapSnapshotDataGrids.js
Source/WebCore/inspector/front-end/HeapSnapshotGridNodes.js
Source/WebCore/inspector/front-end/HeapSnapshotView.js
Source/WebCore/inspector/front-end/ProfilesPanel.js
Source/WebCore/inspector/front-end/profilesPanel.css

index f418ea5..9c4fa0e 100644 (file)
@@ -1,5 +1,41 @@
 2012-05-22  Yury Semikhatsky  <yurys@chromium.org>
 
+        Web Inspector: allow showing selected object in another heap profiler view
+        https://bugs.webkit.org/show_bug.cgi?id=87098
+
+        Reviewed by Vsevolod Vlasov.
+
+        Added 2 context menu actions: 1) to jump from a node in the heap snapshot summary
+        view to the same node in the dominators view; 2) to jump from a node in the dominators
+        view to the same node in the summary view.
+
+        * inspector/front-end/HeapSnapshotDataGrids.js:
+        (WebInspector.HeapSnapshotSortableDataGrid): "sorting complete" event is only dispatched on
+        when the data grid is populated. If we switch to already populated data grid the event is not
+        dispatched. However when switching between different views of a heap snapshot we want to track
+        the moment when the data grid is shown and populated. I added
+        WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown for such cases. The event will always
+        be dispatched after the data grid is shown and its content is populated.
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.wasShown):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype._sortingComplete):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.populateContextMenu.revealInDominatorsView):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.populateContextMenu.else.revealInSummaryView):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype.populateContextMenu):
+        (WebInspector.HeapSnapshotSortableDataGrid.prototype._performSorting):
+        * inspector/front-end/HeapSnapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGenericObjectNode.prototype._createObjectCell):
+        (WebInspector.HeapSnapshotDominatorObjectNode.prototype.retrieveChildBySnapshotObjectId):
+        * inspector/front-end/HeapSnapshotView.js:
+        (WebInspector.HeapSnapshotView.prototype.populateContextMenu):
+        (WebInspector.HeapSnapshotView.prototype.changeView.dataGridContentShown):
+        (WebInspector.HeapSnapshotView.prototype.changeView):
+        (WebInspector.HeapSnapshotView.prototype._onSelectedViewChanged):
+        (WebInspector.HeapSnapshotView.prototype._changeView):
+        * inspector/front-end/ProfilesPanel.js:
+        (WebInspector.ProfilesPanel.prototype._handleContextMenuEvent):
+
+2012-05-22  Yury Semikhatsky  <yurys@chromium.org>
+
         Web Inspector: show more button node should have height multiple of row height
         https://bugs.webkit.org/show_bug.cgi?id=87104
 
index 520449e..4123435 100644 (file)
@@ -44,9 +44,18 @@ WebInspector.HeapSnapshotSortableDataGrid = function(columns)
      * @type {WebInspector.HeapSnapshotGridNode}
      */
     this._highlightedNode = null;
+    /**
+     * @type {boolean}
+     */
+    this._populatedAndSorted = false;
+    this.addEventListener("sorting complete", this._sortingComplete, this);
     this.addEventListener("sorting changed", this.sortingChanged, this);
 }
 
+WebInspector.HeapSnapshotSortableDataGrid.Events = {
+    ContentShown: "ContentShown"
+}
+
 WebInspector.HeapSnapshotSortableDataGrid.prototype = {
     /**
      * @return {number}
@@ -63,6 +72,54 @@ WebInspector.HeapSnapshotSortableDataGrid.prototype = {
             children[i].dispose();
     },
 
+    /**
+     * @override
+     */
+    wasShown: function()
+    {
+        if (this._populatedAndSorted)
+            this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown, this);
+    },
+
+    _sortingComplete: function()
+    {
+        this.removeEventListener("sorting complete", this._sortingComplete, this);
+        this._populatedAndSorted = true;
+        this.dispatchEventToListeners(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown, this);
+    },
+
+    /**
+     * @override
+     */
+    willHide: function()
+    {
+        this._clearCurrentHighlight();
+    },
+
+    /**
+     * @param {WebInspector.ContextMenu} contextMenu
+     */
+    populateContextMenu: function(contextMenu, event)
+    {
+        var td = event.target.enclosingNodeOrSelfWithNodeName("td");
+        if (!td)
+            return;
+        var node = td.heapSnapshotNode;
+        if (node instanceof WebInspector.HeapSnapshotInstanceNode || node instanceof WebInspector.HeapSnapshotObjectNode) {
+            function revealInDominatorsView()
+            {
+                WebInspector.panels.profiles.showObject(node.snapshotNodeId, "Dominators");
+            }
+            contextMenu.appendItem(WebInspector.UIString("Reveal in Dominators View"), revealInDominatorsView.bind(this));
+        } else if (node instanceof WebInspector.HeapSnapshotDominatorObjectNode) {
+            function revealInSummaryView()
+            {
+                WebInspector.panels.profiles.showObject(node.snapshotNodeId, "Summary");
+            }
+            contextMenu.appendItem(WebInspector.UIString("Reveal in Summary View"), revealInSummaryView.bind(this));
+        }
+    },
+
     resetSortingCache: function()
     {
         delete this._lastSortColumnIdentifier;
@@ -167,8 +224,8 @@ WebInspector.HeapSnapshotSortableDataGrid.prototype = {
             if (child.expanded)
                 child.sort();
         }
-        this.recursiveSortingLeave();
         this.updateVisibleNodes();
+        this.recursiveSortingLeave();
     },
 
     appendChildAfterSorting: function(child)
index 9f72b63..ba93a8a 100644 (file)
@@ -385,6 +385,7 @@ WebInspector.HeapSnapshotGenericObjectNode.prototype = {
         cell.addStyleClass("disclosure");
         if (this.depth)
             cell.style.setProperty("padding-left", (this.depth * this.dataGrid.indentWidth) + "px");
+        cell.heapSnapshotNode = this;
         return cell;
     },
 
@@ -1028,6 +1029,9 @@ WebInspector.HeapSnapshotDominatorObjectNode.prototype = {
             callback(child);
         }
 
+        // Make sure hasChildren flag is updated before expanding this node as updateHasChildren response
+        // may not have been received yet.
+        this.hasChildren = true;
         this.expandWithoutPopulate(didExpand.bind(this));
     },
 
index a386b6f..3a7ec41 100644 (file)
@@ -104,7 +104,7 @@ WebInspector.HeapSnapshotView = function(parent, profile)
 
     this.viewSelectElement = document.createElement("select");
     this.viewSelectElement.className = "status-bar-item";
-    this.viewSelectElement.addEventListener("change", this._changeView.bind(this), false);
+    this.viewSelectElement.addEventListener("change", this._onSelectedViewChanged.bind(this), false);
 
     this.views = [{title: "Summary", view: this.constructorsView, grid: this.constructorsDataGrid},
                   {title: "Comparison", view: this.diffView, grid: this.diffDataGrid},
@@ -427,6 +427,14 @@ WebInspector.HeapSnapshotView.prototype = {
         profile.sidebarElement.subtitle = Number.bytesToString(s.totalSize);
     },
 
+    /**
+     * @param {WebInspector.ContextMenu} contextMenu
+     */
+    populateContextMenu: function(contextMenu, event)
+    {
+        this.dataGrid.populateContextMenu(contextMenu, event);
+    },
+
     _selectionChanged: function(event)
     {
         var selectedNode = event.target.selectedNode;
@@ -473,15 +481,18 @@ WebInspector.HeapSnapshotView.prototype = {
             setTimeout(callback, 0);
             return;
         }
-        var grid = this.views[viewIndex].grid;
-        function sortingComplete()
+
+        function dataGridContentShown(event)
         {
-            grid.removeEventListener("sorting complete", sortingComplete, this);
-            setTimeout(callback, 0);
+            var dataGrid = event.data;
+            dataGrid.removeEventListener(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridContentShown, this);
+            if (dataGrid === this.dataGrid)
+                callback();
         }
-        this.views[viewIndex].grid.addEventListener("sorting complete", sortingComplete, this);
+        this.views[viewIndex].grid.addEventListener(WebInspector.HeapSnapshotSortableDataGrid.Events.ContentShown, dataGridContentShown, this);
+
         this.viewSelectElement.selectedIndex = viewIndex;
-        this._changeView({target: {selectedIndex: viewIndex}});
+        this._changeView(viewIndex);
     },
 
     _updateDataSourceAndView: function()
@@ -511,14 +522,17 @@ WebInspector.HeapSnapshotView.prototype = {
         }
     },
 
-    _changeView: function(event)
+    _onSelectedViewChanged: function(event)
     {
-        if (!event || !this._profileUid)
-            return;
-        if (event.target.selectedIndex === this.views.current)
+        this._changeView(event.target.selectedIndex);
+    },
+
+    _changeView: function(selectedIndex)
+    {
+        if (selectedIndex === this.views.current)
             return;
 
-        this.views.current = event.target.selectedIndex;
+        this.views.current = selectedIndex;
         this.currentView.detach();
         var view = this.views[this.views.current];
         this.currentView = view.view;
index 20524f1..4a926eb 100644 (file)
@@ -428,6 +428,8 @@ WebInspector.ProfilesPanel.prototype = {
             return;
         }
         var contextMenu = new WebInspector.ContextMenu();
+        if (this.visibleView instanceof WebInspector.HeapSnapshotView)
+            this.visibleView.populateContextMenu(contextMenu, event);
         contextMenu.appendItem(WebInspector.UIString("Load profile\u2026"), this._fileSelectorElement.click.bind(this._fileSelectorElement));
         contextMenu.show(event);
     },
index a7f2bac..d70c4a0 100644 (file)
@@ -192,6 +192,6 @@ body.inactive .profile-launcher-view-content button.running:not(.status-bar-item
 }
 
 @-webkit-keyframes row_highlight {
-    from {background-color: rgb(255, 255, 120); }
-    to { background-color: white; }
+    from {background-color: rgba(255, 255, 120, 1); }
+    to { background-color: rgba(255, 255, 120, 0); }
 }