Commit 3c2cce4f authored by Brandon Goddard's avatar Brandon Goddard Committed by Commit Bot

Devtools: Context Menu for links in Profiler (Memory and CPU) Datagrid

This change adds a context menu entry for the links that appear
in the 'Functions' column in Heavy (bottom-up) and Top Down views in
the Memory Allocation Sample and Javascript CPU Profiler tools.

This allows the keyboard users to access these links with the context
menu key.

Note that this change is dependent on
https://chromium-review.googlesource.com/c/chromium/src/+/1729554
for the context menu key in the DataGrid to target the
currently selected node.

Before: https://imgur.com/ErkPbIc

After: https://imgur.com/a3R3rDB
Bug: 963183
Change-Id: I3d5068b0efff0c31a46aeb6ee11ff5feb85bc58b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1832479Reviewed-by: default avatarLorne Mitchell <lomitch@microsoft.com>
Commit-Queue: Brandon Goddard <brgoddar@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#706600}
parent 7bd63cba
...@@ -51,6 +51,8 @@ Profiler.ProfileDataGridNode = class extends DataGrid.DataGridNode { ...@@ -51,6 +51,8 @@ Profiler.ProfileDataGridNode = class extends DataGrid.DataGridNode {
this.functionName = UI.beautifyFunctionName(profileNode.functionName); this.functionName = UI.beautifyFunctionName(profileNode.functionName);
this._deoptReason = profileNode.deoptReason || ''; this._deoptReason = profileNode.deoptReason || '';
this.url = profileNode.url; this.url = profileNode.url;
/** @type {?Element} */
this.linkElement = null;
} }
/** /**
...@@ -188,6 +190,7 @@ Profiler.ProfileDataGridNode = class extends DataGrid.DataGridNode { ...@@ -188,6 +190,7 @@ Profiler.ProfileDataGridNode = class extends DataGrid.DataGridNode {
} }
urlElement.style.maxWidth = '75%'; urlElement.style.maxWidth = '75%';
cell.appendChild(urlElement); cell.appendChild(urlElement);
this.linkElement = urlElement;
break; break;
default: default:
......
...@@ -32,6 +32,7 @@ Profiler.ProfileView = class extends UI.SimpleView { ...@@ -32,6 +32,7 @@ Profiler.ProfileView = class extends UI.SimpleView {
this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, this._sortProfile, this); this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged, this._sortProfile, this);
this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode, this._nodeSelected.bind(this, true)); this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode, this._nodeSelected.bind(this, true));
this.dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode, this._nodeSelected.bind(this, false)); this.dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode, this._nodeSelected.bind(this, false));
this.dataGrid.setRowContextMenuCallback(this._populateContextMenu.bind(this));
this.viewSelectComboBox = new UI.ToolbarComboBox(this._changeView.bind(this), ls`Profile view mode`); this.viewSelectComboBox = new UI.ToolbarComboBox(this._changeView.bind(this), ls`Profile view mode`);
...@@ -174,6 +175,17 @@ Profiler.ProfileView = class extends UI.SimpleView { ...@@ -174,6 +175,17 @@ Profiler.ProfileView = class extends UI.SimpleView {
return this._topDownProfileDataGridTree; return this._topDownProfileDataGridTree;
} }
/**
* @param {!UI.ContextMenu} contextMenu
* @param {!DataGrid.DataGridNode} gridNode
*/
_populateContextMenu(contextMenu, gridNode) {
const node = /** @type {!Profiler.ProfileDataGridNode} */ (gridNode);
if (node.linkElement && !contextMenu.containsTarget(node.linkElement)) {
contextMenu.appendApplicableItems(node.linkElement);
}
}
/** /**
* @override * @override
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment