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 <pecoraro@apple.com> 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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@203243 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js b/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
index e72d0cf..b666705 100644
--- a/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
+++ b/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
@@ -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);