- Revision
- 203243
- Author
- [email protected]
- Date
- 2016-07-14 14:42:42 -0700 (Thu, 14 Jul 2016)
Log Message
Web Inspector: Maintain selected function when switching between different profile representations
https://bugs.webkit.org/show_bug.cgi?id=159778
<rdar://problem/27355913>
Patch by Joseph Pecoraro <[email protected]> on 2016-07-14
Reviewed by Timothy Hatcher.
* UserInterface/Models/CallingContextTree.js:
(WebInspector.CCTNode):
(WebInspector.CCTNode.prototype.get hash):
(WebInspector.CCTNode.prototype.findOrMakeChild):
(WebInspector.CCTNode.prototype.equals):
Expose the hash so two nodes can be compared cheaply.
* UserInterface/Views/ProfileView.js:
(WebInspector.ProfileView.prototype._repopulateDataGridFromTree):
(WebInspector.ProfileView.prototype._restoreSharedState):
(WebInspector.ProfileView.prototype._dataGridNodeSelected):
Share data between multiple ProfileViews. Currently just remembering
and restoring the selected function.
* UserInterface/Views/ScriptProfileTimelineView.js:
(WebInspector.ScriptProfileTimelineView):
(WebInspector.ScriptProfileTimelineView.prototype._showProfileViewForOrientation):
Include the shared data when constructing new ProfileViews.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (203242 => 203243)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-07-14 21:39:15 UTC (rev 203242)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-07-14 21:42:42 UTC (rev 203243)
@@ -1,3 +1,30 @@
+2016-07-14 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Maintain selected function when switching between different profile representations
+ https://bugs.webkit.org/show_bug.cgi?id=159778
+ <rdar://problem/27355913>
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Models/CallingContextTree.js:
+ (WebInspector.CCTNode):
+ (WebInspector.CCTNode.prototype.get hash):
+ (WebInspector.CCTNode.prototype.findOrMakeChild):
+ (WebInspector.CCTNode.prototype.equals):
+ Expose the hash so two nodes can be compared cheaply.
+
+ * UserInterface/Views/ProfileView.js:
+ (WebInspector.ProfileView.prototype._repopulateDataGridFromTree):
+ (WebInspector.ProfileView.prototype._restoreSharedState):
+ (WebInspector.ProfileView.prototype._dataGridNodeSelected):
+ Share data between multiple ProfileViews. Currently just remembering
+ and restoring the selected function.
+
+ * UserInterface/Views/ScriptProfileTimelineView.js:
+ (WebInspector.ScriptProfileTimelineView):
+ (WebInspector.ScriptProfileTimelineView.prototype._showProfileViewForOrientation):
+ Include the shared data when constructing new ProfileViews.
+
2016-07-13 Matt Baker <[email protected]>
Uncaught Exception: TypeError: null is not an object (evaluating 'this._contentViewContainer.currentContentView.showsFilterBar')
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CallingContextTree.js (203242 => 203243)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CallingContextTree.js 2016-07-14 21:39:15 UTC (rev 203242)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CallingContextTree.js 2016-07-14 21:42:42 UTC (rev 203243)
@@ -170,7 +170,7 @@
WebInspector.CCTNode = class CCTNode extends WebInspector.Object
{
- constructor(sourceID, line, column, name, url)
+ constructor(sourceID, line, column, name, url, hash)
{
super();
@@ -187,6 +187,8 @@
this._leafTimestamps = [];
this._leafDurations = [];
this._expressionLocations = {}; // Keys are "line:column" strings. Values are arrays of timestamps in sorted order.
+
+ this._hash = hash || WebInspector.CCTNode._hash(this);
}
// Static and Private
@@ -204,6 +206,7 @@
get name() { return this._name; }
get uid() { return this._uid; }
get url() { return this._url; }
+ get hash() { return this._hash; }
hasChildrenInTimeRange(startTime, endTime)
{
@@ -276,7 +279,7 @@
let node = this._children[hash];
if (node)
return node;
- node = new WebInspector.CCTNode(stackFrame.sourceID, stackFrame.line, stackFrame.column, stackFrame.name, stackFrame.url);
+ node = new WebInspector.CCTNode(stackFrame.sourceID, stackFrame.line, stackFrame.column, stackFrame.name, stackFrame.url, hash);
this._children[hash] = node;
return node;
}
@@ -322,7 +325,7 @@
equals(other)
{
- return WebInspector.CCTNode._hash(this) === WebInspector.CCTNode._hash(other);
+ return this._hash === other.hash;
}
toCPUProfileNode(numSamples, startTime, endTime)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProfileView.js (203242 => 203243)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ProfileView.js 2016-07-14 21:39:15 UTC (rev 203242)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProfileView.js 2016-07-14 21:42:42 UTC (rev 203243)
@@ -25,7 +25,7 @@
WebInspector.ProfileView = class ProfileView extends WebInspector.ContentView
{
- constructor(callingContextTree)
+ constructor(callingContextTree, extraArguments)
{
super(callingContextTree);
@@ -69,6 +69,10 @@
this._dataGrid.sortOrder = WebInspector.DataGrid.SortOrder.Descending;
this._dataGrid.createSettings("profile-view");
+ // Currently we create a new ProfileView for each CallingContextTree, so
+ // to share state between them, use a common shared data object.
+ this._sharedData = extraArguments;
+
this.addSubview(this._dataGrid);
}
@@ -151,10 +155,26 @@
_repopulateDataGridFromTree()
{
this._dataGrid.removeChildren();
+
for (let child of this._profileDataGridTree.children)
this._dataGrid.appendChild(child);
+
+ this._restoreSharedState();
}
+ _restoreSharedState()
+ {
+ const skipHidden = false;
+ const stayWithin = this._dataGrid;
+ const dontPopulate = true;
+
+ if (this._sharedData.selectedNodeHash) {
+ let nodeToSelect = this._dataGrid.findNode((node) => node.callingContextTreeNode.hash === this._sharedData.selectedNodeHash, skipHidden, stayWithin, dontPopulate);
+ if (nodeToSelect)
+ nodeToSelect.revealAndSelect();
+ }
+ }
+
_pathComponentClicked(event)
{
if (!event.data.pathComponent)
@@ -201,6 +221,8 @@
if (newSelectedNode) {
this._removeGuidanceElement(WebInspector.ProfileView.GuidanceType.Selected, newSelectedNode);
newSelectedNode.forEachChildInSubtree((node) => this._appendGuidanceElement(WebInspector.ProfileView.GuidanceType.Selected, node, newSelectedNode));
+
+ this._sharedData.selectedNodeHash = newSelectedNode.callingContextTreeNode.hash;
}
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js (203242 => 203243)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js 2016-07-14 21:39:15 UTC (rev 203242)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js 2016-07-14 21:42:42 UTC (rev 203243)
@@ -39,6 +39,10 @@
this._lastLayoutStartTime = undefined;
this._lastLayoutEndTime = undefined;
+ this._sharedProfileViewData = {
+ selectedNodeHash: null,
+ };
+
if (!WebInspector.ScriptProfileTimelineView.profileOrientationSetting)
WebInspector.ScriptProfileTimelineView.profileOrientationSetting = new WebInspector.Setting("script-profile-timeline-view-profile-orientation-setting", WebInspector.ScriptProfileTimelineView.ProfileOrientation.TopDown);
if (!WebInspector.ScriptProfileTimelineView.profileTypeSetting)
@@ -179,7 +183,7 @@
}
let callingContextTree = this._callingContextTreeForOrientation(profileOrientation, profileViewType);
- this._profileView = new WebInspector.ProfileView(callingContextTree);
+ this._profileView = new WebInspector.ProfileView(callingContextTree, this._sharedProfileViewData);
this._profileView.addEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._profileViewSelectionPathComponentsDidChange, this);
this.addSubview(this._profileView);