Web Inspector: keyboard navigation through comparison view in heap profiler should...
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jan 2012 16:17:01 +0000 (16:17 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Jan 2012 16:17:01 +0000 (16:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77326

Keyboard navigation in the detailed heap snapshot view now updates retainers view.

Reviewed by Pavel Feldman.

* inspector/front-end/DataGrid.js: Added SelectedNode/DeselectedNode events to DataGrid.
(WebInspector.DataGridNode.prototype.select):
(WebInspector.DataGridNode.prototype.deselect):
* inspector/front-end/DetailedHeapshotView.js:
(WebInspector.DetailedHeapshotView.prototype._selectionChanged):
(WebInspector.DetailedHeapshotView.prototype._setRetainmentDataGridSource):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DataGrid.js
Source/WebCore/inspector/front-end/DetailedHeapshotView.js

index ea1cb2e..b72ffda 100644 (file)
@@ -1,5 +1,21 @@
 2012-01-30  Yury Semikhatsky  <yurys@chromium.org>
 
+        Web Inspector: keyboard navigation through comparison view in heap profiler should update retainers view
+        https://bugs.webkit.org/show_bug.cgi?id=77326
+
+        Keyboard navigation in the detailed heap snapshot view now updates retainers view.
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/DataGrid.js: Added SelectedNode/DeselectedNode events to DataGrid.
+        (WebInspector.DataGridNode.prototype.select):
+        (WebInspector.DataGridNode.prototype.deselect):
+        * inspector/front-end/DetailedHeapshotView.js:
+        (WebInspector.DetailedHeapshotView.prototype._selectionChanged):
+        (WebInspector.DetailedHeapshotView.prototype._setRetainmentDataGridSource):
+
+2012-01-30  Yury Semikhatsky  <yurys@chromium.org>
+
         Unreviewed. Fix inspector front-end compilation.
 
         * inspector/front-end/RemoteObject.js:
index f5a21f9..036cb4f 100644 (file)
@@ -162,6 +162,11 @@ WebInspector.DataGrid = function(columns, editCallback, deleteCallback)
     this._columnWidthsInitialized = false;
 }
 
+WebInspector.DataGrid.Events = {
+    SelectedNode: "SelectedNode",
+    DeselectedNode: "DeselectedNode"
+}
+
 /**
  * @param {Array.<string>} columnNames
  * @param {Array.<string>} values
@@ -1464,8 +1469,10 @@ WebInspector.DataGridNode.prototype = {
         if (this._element)
             this._element.addStyleClass("selected");
 
-        if (!supressSelectedEvent)
+        if (!supressSelectedEvent) {
             this.dispatchEventToListeners("selected");
+            this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Events.SelectedNode);
+        }
     },
 
     revealAndSelect: function()
@@ -1488,8 +1495,10 @@ WebInspector.DataGridNode.prototype = {
         if (this._element)
             this._element.removeStyleClass("selected");
 
-        if (!supressDeselectedEvent)
+        if (!supressDeselectedEvent) {
             this.dispatchEventToListeners("deselected");
+            this.dataGrid.dispatchEventToListeners(WebInspector.DataGrid.Events.DeselectedNode);
+        }
     },
 
     traverseNextNode: function(skipHidden, stayWithin, dontPopulate, info)
index 77862ed..2ffb940 100644 (file)
@@ -429,29 +429,29 @@ WebInspector.DetailedHeapshotView = function(parent, profile)
     this.containmentView = new WebInspector.View();
     this.containmentView.element.addStyleClass("view");
     this.containmentDataGrid = new WebInspector.HeapSnapshotContainmentDataGrid();
-    this.containmentDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.containmentDataGrid.element.addEventListener("mousedown", this._mouseDownInContentsGrid.bind(this), true);
     this.containmentDataGrid.show(this.containmentView.element);
+    this.containmentDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, this._selectionChanged, this);
 
     this.constructorsView = new WebInspector.View();
     this.constructorsView.element.addStyleClass("view");
     this.constructorsDataGrid = new WebInspector.HeapSnapshotConstructorsDataGrid();
-    this.constructorsDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.constructorsDataGrid.element.addEventListener("mousedown", this._mouseDownInContentsGrid.bind(this), true);
     this.constructorsDataGrid.show(this.constructorsView.element);
+    this.constructorsDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, this._selectionChanged, this);
 
     this.diffView = new WebInspector.View();
     this.diffView.element.addStyleClass("view");
     this.diffDataGrid = new WebInspector.HeapSnapshotDiffDataGrid();
-    this.diffDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.diffDataGrid.show(this.diffView.element);
+    this.diffDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, this._selectionChanged, this);
 
     this.dominatorView = new WebInspector.View();
     this.dominatorView.element.addStyleClass("view");
     this.dominatorDataGrid = new WebInspector.HeapSnapshotDominatorsDataGrid();
-    this.dominatorDataGrid.element.addEventListener("click", this._mouseClickInContentsGrid.bind(this), true);
     this.dominatorDataGrid.element.addEventListener("mousedown", this._mouseDownInContentsGrid.bind(this), true);
     this.dominatorDataGrid.show(this.dominatorView.element);
+    this.dominatorDataGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, this._selectionChanged, this);
 
     this.retainmentViewHeader = document.createElement("div");
     this.retainmentViewHeader.addStyleClass("retainers-view-header");
@@ -809,18 +809,15 @@ WebInspector.DetailedHeapshotView.prototype = {
         profile.sidebarElement.subtitle = Number.bytesToString(s.totalSize);
     },
 
-    _mouseClickInContentsGrid: function(event)
+    _selectionChanged: function(event)
     {
-        var cell = event.target.enclosingNodeOrSelfWithNodeName("td");
-        if (!cell || (!cell.hasStyleClass("object-column")))
-            return;
-        var row = event.target.enclosingNodeOrSelfWithNodeName("tr");
-        if (!row)
-            return;
-        var nodeItem = row._dataGridNode;
-        if (!nodeItem || nodeItem.isEventWithinDisclosureTriangle(event))
-            return;
-        if (nodeItem.snapshotNodeIndex)
+        var selectedNode = event.target.selectedNode;
+        this._setRetainmentDataGridSource(selectedNode);
+    },
+
+    _setRetainmentDataGridSource: function(nodeItem)
+    {
+        if (nodeItem && nodeItem.snapshotNodeIndex)
             this.retainmentDataGrid.setDataSource(this, nodeItem.isDeletedNode ? nodeItem.dataGrid.baseSnapshot : nodeItem.dataGrid.snapshot, nodeItem.snapshotNodeIndex, nodeItem.isDeletedNode ? this.baseSelectElement.childNodes[this.baseSelectElement.selectedIndex].label + " | " : "");
         else
             this.retainmentDataGrid.reset();