Title: [248198] trunk/Source/WebInspectorUI
Revision
248198
Author
[email protected]
Date
2019-08-03 01:56:05 -0700 (Sat, 03 Aug 2019)

Log Message

Web Inspector: Heap Snapshot Views should be searchable
https://bugs.webkit.org/show_bug.cgi?id=157582
<rdar://problem/26228629>

Reviewed by Joseph Pecoraro.

Without the ability to filter/search, it's far more difficult to find objects of interest.
Rather than spending time scrolling through the entire heap snapshot or sorting by "Name",
a simple filter/search (which also uses the global search settings) is almost instant.

* UserInterface/Views/HeapAllocationsTimelineView.js:
(WI.HeapAllocationsTimelineView.prototype.updateFilter): Addded.
(WI.HeapAllocationsTimelineView.prototype.get showsFilterBar): Deleted.
* UserInterface/Views/HeapSnapshotClusterContentView.js:
(WI.HeapSnapshotClusterContentView.prototype.updateFilter): Added.
* UserInterface/Views/HeapSnapshotContentView.js:
(WI.HeapSnapshotContentView):
(WI.HeapSnapshotContentView.prototype.updateFilter): Added.
(WI.HeapSnapshotContentView.prototype.dataGridMatchNodeAgainstCustomFilters): Added.
(WI.HeapSnapshotContentView.prototype.dataGridMatchShouldPopulateWhenFilteringNode): Added.
* UserInterface/Views/DataGrid.js:
(WI.DataGrid.prototype._updateFilter.createIteratorForNodesToBeFiltered):
Don't attempt to populate each heap snapshot `WI.DataGridNode` when filtering, as that can
quickly exhaust memory due to the sheer size of a heap snapshot.

* UserInterface/Base/Main.js:
(WI._find):
* UserInterface/Views/TimelineTabContentView.js:
(WI.TimelineTabContentView.prototype.get canHandleFindEvent): Added.
(WI.TimelineTabContentView.prototype.handleFindEvent): Added.
* UserInterface/Views/TimelineRecordingContentView.js:
(WI.TimelineRecordingContentView.prototype.get canFocusFilterBar): Added.
(WI.TimelineRecordingContentView.prototype.focusFilterBar): Added.
* UserInterface/Views/FilterBar.js:
(WI.FilterBar.prototype.focus): Added.
Allow the current tab to intercept the find shortcut and do something custom. In the case
of a `WI.TimelineTabContentView`, declare that it can handle the find event if the displayed
content view (`WI.TimelineRecordingContentView`) can focus it's filter bar. If so, when the
find shortcut is triggered, focus the filter bar.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (248197 => 248198)


--- trunk/Source/WebInspectorUI/ChangeLog	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/ChangeLog	2019-08-03 08:56:05 UTC (rev 248198)
@@ -1,5 +1,47 @@
 2019-08-03  Devin Rousso  <[email protected]>
 
+        Web Inspector: Heap Snapshot Views should be searchable
+        https://bugs.webkit.org/show_bug.cgi?id=157582
+        <rdar://problem/26228629>
+
+        Reviewed by Joseph Pecoraro.
+
+        Without the ability to filter/search, it's far more difficult to find objects of interest.
+        Rather than spending time scrolling through the entire heap snapshot or sorting by "Name",
+        a simple filter/search (which also uses the global search settings) is almost instant.
+
+        * UserInterface/Views/HeapAllocationsTimelineView.js:
+        (WI.HeapAllocationsTimelineView.prototype.updateFilter): Addded.
+        (WI.HeapAllocationsTimelineView.prototype.get showsFilterBar): Deleted.
+        * UserInterface/Views/HeapSnapshotClusterContentView.js:
+        (WI.HeapSnapshotClusterContentView.prototype.updateFilter): Added.
+        * UserInterface/Views/HeapSnapshotContentView.js:
+        (WI.HeapSnapshotContentView):
+        (WI.HeapSnapshotContentView.prototype.updateFilter): Added.
+        (WI.HeapSnapshotContentView.prototype.dataGridMatchNodeAgainstCustomFilters): Added.
+        (WI.HeapSnapshotContentView.prototype.dataGridMatchShouldPopulateWhenFilteringNode): Added.
+        * UserInterface/Views/DataGrid.js:
+        (WI.DataGrid.prototype._updateFilter.createIteratorForNodesToBeFiltered):
+        Don't attempt to populate each heap snapshot `WI.DataGridNode` when filtering, as that can
+        quickly exhaust memory due to the sheer size of a heap snapshot.
+
+        * UserInterface/Base/Main.js:
+        (WI._find):
+        * UserInterface/Views/TimelineTabContentView.js:
+        (WI.TimelineTabContentView.prototype.get canHandleFindEvent): Added.
+        (WI.TimelineTabContentView.prototype.handleFindEvent): Added.
+        * UserInterface/Views/TimelineRecordingContentView.js:
+        (WI.TimelineRecordingContentView.prototype.get canFocusFilterBar): Added.
+        (WI.TimelineRecordingContentView.prototype.focusFilterBar): Added.
+        * UserInterface/Views/FilterBar.js:
+        (WI.FilterBar.prototype.focus): Added.
+        Allow the current tab to intercept the find shortcut and do something custom. In the case
+        of a `WI.TimelineTabContentView`, declare that it can handle the find event if the displayed
+        content view (`WI.TimelineRecordingContentView`) can focus it's filter bar. If so, when the
+        find shortcut is triggered, focus the filter bar.
+
+2019-08-03  Devin Rousso  <[email protected]>
+
         Web Inspector: CSS Formatter: comments with an escape character aren't formatted
         https://bugs.webkit.org/show_bug.cgi?id=200168
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -2486,6 +2486,12 @@
 
 WI._find = function(event)
 {
+    let tabContentView = WI.tabBrowser.selectedTabContentView;
+    if (tabContentView && tabContentView.canHandleFindEvent) {
+        tabContentView.handleFindEvent(event);
+        return;
+    }
+
     let contentBrowser = WI._focusedOrVisibleContentBrowser();
     if (!contentBrowser)
         return;

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DataGrid.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -1860,13 +1860,17 @@
 
         function *createIteratorForNodesToBeFiltered()
         {
-            // Don't populate if we don't have any active filters.
-            // We only need to populate when a filter needs to reveal.
-            let dontPopulate = !this.hasFilters();
+            let hasFilters = this.hasFilters();
 
             let currentNode = this._rows[0];
             while (currentNode && !currentNode.root) {
                 yield currentNode;
+
+                // Don't populate if we don't have any active filters.
+                // We only need to populate when a filter needs to reveal.
+                let dontPopulate = !hasFilters;
+                if (hasFilters && this._filterDelegate && this._filterDelegate.dataGridMatchShouldPopulateWhenFilteringNode)
+                    dontPopulate = this._filterDelegate.dataGridMatchShouldPopulateWhenFilteringNode(currentNode);
                 currentNode = currentNode.traverseNextNode(false, null, dontPopulate);
             }
         }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -116,6 +116,15 @@
         this._element.classList.toggle("active", !!active);
     }
 
+    focus()
+    {
+        // FIXME: Workaround for: <https://webkit.org/b/149504> Caret missing from <input> after clearing text and calling select()
+        if (!this._inputField.value.length)
+            this._inputField.focus();
+        else
+            this._inputField.select();
+    }
+
     clear()
     {
         this._filterFunctionsMap.clear();

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineView.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -183,9 +183,6 @@
 
     // Protected
 
-    // FIXME: <https://webkit.org/b/157582> Web Inspector: Heap Snapshot Views should be searchable
-    get showsFilterBar() { return this._showingSnapshotList; }
-
     get navigationItems()
     {
         if (this._showingSnapshotList) {
@@ -298,7 +295,13 @@
 
     updateFilter(filters)
     {
-        this._dataGrid.filterText = filters ? filters.text : "";
+        if (this._showingSnapshotList) {
+            this._dataGrid.filterText = filters ? filters.text : "";
+            return;
+        }
+
+        console.assert(this._contentViewContainer.currentContentView);
+        this._contentViewContainer.currentContentView.updateFilter(filters);
     }
 
     // Private

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClusterContentView.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClusterContentView.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotClusterContentView.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -175,6 +175,12 @@
         return this._showContentViewForIdentifier(WI.HeapSnapshotClusterContentView.ObjectGraphIdentifier);
     }
 
+    updateFilter(filters)
+    {
+        console.assert(this._contentViewContainer.currentContentView);
+        this._contentViewContainer.currentContentView.updateFilter(filters);
+    }
+
     // Private
 
     _supportsObjectGraph()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotContentView.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotContentView.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapSnapshotContentView.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -42,6 +42,7 @@
         this._dataGrid = new WI.DataGrid(columns);
         this._dataGrid.sortColumnIdentifier = "retainedSize";
         this._dataGrid.sortOrder = WI.DataGrid.SortOrder.Descending;
+        this._dataGrid.filterDelegate = this;
         this._dataGrid.createSettings(identifier);
         this._dataGrid.addEventListener(WI.DataGrid.Event.SortChanged, this._sortDataGrid, this);
 
@@ -56,6 +57,28 @@
         this._dataGrid.updateLayout();
     }
 
+    // Public
+
+    updateFilter(filters)
+    {
+        this._dataGrid.filterText = filters ? filters.text : "";
+    }
+
+    // DataGrid filter delegate
+
+    dataGridMatchNodeAgainstCustomFilters(node)
+    {
+        console.assert(node);
+        if (node instanceof WI.HeapSnapshotInstanceFetchMoreDataGridNode)
+            return false;
+        return true;
+    }
+
+    dataGridMatchShouldPopulateWhenFilteringNode(node)
+    {
+        return true;
+    }
+
     // Protected
 
     get navigationItems()

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineRecordingContentView.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -277,6 +277,16 @@
         this._clearTimeline();
     }
 
+    get canFocusFilterBar()
+    {
+        return !this._filterBarNavigationItem.hidden;
+    }
+
+    focusFilterBar()
+    {
+        this._filterBarNavigationItem.filterBar.focus();
+    }
+
     // ContentBrowser delegate
 
     contentBrowserTreeElementForRepresentedObject(contentBrowser, representedObject)

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js (248197 => 248198)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js	2019-08-03 08:52:53 UTC (rev 248197)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js	2019-08-03 08:56:05 UTC (rev 248198)
@@ -341,6 +341,18 @@
         return representedObject instanceof WI.TimelineRecording;
     }
 
+    get canHandleFindEvent()
+    {
+        console.assert(this._displayedContentView);
+        return this._displayedContentView.canFocusFilterBar;
+    }
+
+    handleFindEvent(event)
+    {
+        console.assert(this._displayedContentView);
+        this._displayedContentView.focusFilterBar();
+    }
+
     async handleFileDrop(files)
     {
         await WI.FileUtilities.readJSON(files, (result) => WI.timelineManager.processJSON(result));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to