Web Inspector: Script ProfileViews should be searchable
https://bugs.webkit.org/show_bug.cgi?id=157581
<rdar://problem/26228530>

Reviewed by Joseph Pecoraro.

* UserInterface/Views/DataGrid.js:
(WebInspector.DataGrid.prototype.get filterText):
Make filterText readable.

* UserInterface/Views/ProfileDataGridNode.js:
(WebInspector.ProfileDataGridNode.prototype.get callingContextTreeNode):
(WebInspector.ProfileDataGridNode.prototype.filterableDataForColumn):
Add filterable data for the "function" column.
(WebInspector.ProfileDataGridNode.prototype._updateChildrenForModifiers):
(WebInspector.ProfileDataGridNode.prototype.get node): Deleted.
Renamed callingContextTreeNode to be less ambiguous.

* UserInterface/Views/ProfileDataGridTree.js:
(WebInspector.ProfileDataGridTree.prototype._updateCurrentFocusDetails):

* UserInterface/Views/ProfileView.js:
(WebInspector.ProfileView.prototype.get dataGrid):
Expose data grid for use in parent view.

* UserInterface/Views/ScriptClusterTimelineView.js:
(WebInspector.ScriptClusterTimelineView.prototype.selectRecord):
Drive-by fix: forward property to current child TimelineView.

* UserInterface/Views/ScriptProfileTimelineView.js:
(WebInspector.ScriptProfileTimelineView):
(WebInspector.ScriptProfileTimelineView.prototype._scopeBarSelectionDidChange):
(WebInspector.ScriptProfileTimelineView.prototype._showProfileViewForOrientation):
Helper function to switch profile views. Persist filter text when
switching to the new profile view.

(WebInspector.ScriptProfileTimelineView.prototype.get showsFilterBar): Deleted.
Remove FIXME and show filter bar.

* UserInterface/Views/TimelineView.js:
(WebInspector.TimelineView.prototype.setupDataGrid):
Support switching to a new data grid.
(WebInspector.TimelineView.prototype.dataGridMatchNodeAgainstCustomFilters):
Hooking up filtering causes data grid nodes to be filtered based on the
ruler selection. Although ScriptProfileTimelineView performs its own
time-based filtering, this is necessary to prevent an assert.

(WebInspector.TimelineView.prototype._timelineDataGridSelectedNodeChanged):
(WebInspector.TimelineView.prototype._timelineDataGridNodeWasFiltered):
Converted arrow functions to member functions to allow unregistering
event listeners on outgoing data grid when swapping grids.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200873 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js b/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
index 1540510..6d59e94 100644
--- a/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
+++ b/Source/WebInspectorUI/UserInterface/Views/ScriptProfileTimelineView.js
@@ -42,10 +42,7 @@
         if (!WebInspector.ScriptProfileTimelineView.profileOrientationSetting)
             WebInspector.ScriptProfileTimelineView.profileOrientationSetting = new WebInspector.Setting("script-profile-timeline-view-profile-orientation-setting", WebInspector.ScriptProfileTimelineView.ProfileOrientation.TopDown);
 
-        let callingContextTree = this._callingContextTreeForOrientation(WebInspector.ScriptProfileTimelineView.profileOrientationSetting.value);
-        this._profileView = new WebInspector.ProfileView(callingContextTree);
-        this._profileView.addEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._profileViewSelectionPathComponentsDidChange, this);
-        this.addSubview(this._profileView);
+        this._showProfileViewForOrientation(WebInspector.ScriptProfileTimelineView.profileOrientationSetting.value);
 
         let scopeBarItems = [
             new WebInspector.ScopeBarItem(WebInspector.ScriptProfileTimelineView.ProfileOrientation.TopDown, WebInspector.UIString("Top Down"), true),
@@ -61,17 +58,12 @@
         this._updateClearFocusNodesButtonItem();
 
         timeline.addEventListener(WebInspector.Timeline.Event.Refreshed, this._scriptTimelineRecordRefreshed, this);
-
-        // FIXME: Support filtering the ProfileView.
     }
 
     // Public
 
     get showsLiveRecordingData() { return false; }
 
-    // FIXME: <https://webkit.org/b/157581> Web Inspector: Script ProfileViews should be searchable
-    get showsFilterBar() { return false; }
-
     // Protected
 
     closed()
@@ -130,17 +122,9 @@
     {
         let currentOrientation = WebInspector.ScriptProfileTimelineView.profileOrientationSetting.value;
         let newOrientation = this._profileOrientationScopeBar.selectedItems[0].id;
-        let callingContextTree = this._callingContextTreeForOrientation(newOrientation);
 
         WebInspector.ScriptProfileTimelineView.profileOrientationSetting.value = newOrientation;
-
-        this.removeSubview(this._profileView);
-        this._profileView.removeEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._profileViewSelectionPathComponentsDidChange, this);
-
-        this._profileView = new WebInspector.ProfileView(callingContextTree);
-
-        this._profileView.addEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._profileViewSelectionPathComponentsDidChange, this);
-        this.addSubview(this._profileView);
+        this._showProfileViewForOrientation(newOrientation);
 
         this.dispatchEventToListeners(WebInspector.ContentView.Event.SelectionPathComponentsDidChange);
 
@@ -148,6 +132,26 @@
         this.needsLayout();
     }
 
+    _showProfileViewForOrientation(orientation)
+    {
+        let filterText;
+        if (this._profileView) {
+            this._profileView.removeEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._profileViewSelectionPathComponentsDidChange, this);
+            this.removeSubview(this._profileView);
+            filterText = this._profileView.dataGrid.filterText;
+        }
+
+        let callingContextTree = this._callingContextTreeForOrientation(orientation);
+        this._profileView = new WebInspector.ProfileView(callingContextTree);
+        this._profileView.addEventListener(WebInspector.ContentView.Event.SelectionPathComponentsDidChange, this._profileViewSelectionPathComponentsDidChange, this);
+
+        this.addSubview(this._profileView);
+        this.setupDataGrid(this._profileView.dataGrid);
+
+        if (filterText)
+            this._profileView.dataGrid.filterText = filterText;
+    }
+
     _updateClearFocusNodesButtonItem()
     {
         this._clearFocusNodesButtonItem.enabled = this._profileView.hasFocusNodes();