Web Inspector: REGRESSION: selection in network table is lost when new entries are...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Oct 2018 20:52:12 +0000 (20:52 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 Oct 2018 20:52:12 +0000 (20:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190362

Reviewed by Matt Baker.

The `_selectedRows` list is cleared each time `reloadData` is called, meaning that
`WI.Table` expects its "owner" to restore the selection (since it doesn't know how). As a
result, `WI.NetworkTableContentView` needs to call `selectRow` _after_ `reloadData` is
called, not before.

* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.prototype.tableSortChanged):
(WI.NetworkTableContentView.prototype._populateNameCell):
(WI.NetworkTableContentView.prototype._processPendingEntries):
(WI.NetworkTableContentView.prototype._insertResourceAndReloadTable):
(WI.NetworkTableContentView.prototype._updateSort): Added.
(WI.NetworkTableContentView.prototype._updateFilteredEntries):
(WI.NetworkTableContentView.prototype._reloadTable): Added.
(WI.NetworkTableContentView.prototype._resetFilters):
(WI.NetworkTableContentView.prototype._typeFilterScopeBarSelectionChanged):
(WI.NetworkTableContentView.prototype._handleGroupByDOMNodeCheckedDidChange):
(WI.NetworkTableContentView.prototype._urlFilterDidChange):
(WI.NetworkTableContentView.prototype._updateSortAndFilteredEntries): Deleted.

* UserInterface/Views/Table.js:
(WI.Table.prototype.reloadData):
Ensure that the `_selectedRowIndex` is also reset.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237016 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
Source/WebInspectorUI/UserInterface/Views/Table.js

index 17d8059..ad2b2a1 100644 (file)
@@ -1,5 +1,35 @@
 2018-10-10  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: REGRESSION: selection in network table is lost when new entries are added
+        https://bugs.webkit.org/show_bug.cgi?id=190362
+
+        Reviewed by Matt Baker.
+
+        The `_selectedRows` list is cleared each time `reloadData` is called, meaning that
+        `WI.Table` expects its "owner" to restore the selection (since it doesn't know how). As a
+        result, `WI.NetworkTableContentView` needs to call `selectRow` _after_ `reloadData` is
+        called, not before.
+
+        * UserInterface/Views/NetworkTableContentView.js:
+        (WI.NetworkTableContentView.prototype.tableSortChanged):
+        (WI.NetworkTableContentView.prototype._populateNameCell):
+        (WI.NetworkTableContentView.prototype._processPendingEntries):
+        (WI.NetworkTableContentView.prototype._insertResourceAndReloadTable):
+        (WI.NetworkTableContentView.prototype._updateSort): Added.
+        (WI.NetworkTableContentView.prototype._updateFilteredEntries):
+        (WI.NetworkTableContentView.prototype._reloadTable): Added.
+        (WI.NetworkTableContentView.prototype._resetFilters):
+        (WI.NetworkTableContentView.prototype._typeFilterScopeBarSelectionChanged):
+        (WI.NetworkTableContentView.prototype._handleGroupByDOMNodeCheckedDidChange):
+        (WI.NetworkTableContentView.prototype._urlFilterDidChange):
+        (WI.NetworkTableContentView.prototype._updateSortAndFilteredEntries): Deleted.
+
+        * UserInterface/Views/Table.js:
+        (WI.Table.prototype.reloadData):
+        Ensure that the `_selectedRowIndex` is also reset.
+
+2018-10-10  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: notify the frontend when a canvas has started recording via console.record
         https://bugs.webkit.org/show_bug.cgi?id=190306
 
index 785c71f..22f59c7 100644 (file)
@@ -332,10 +332,9 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         for (let nodeEntry of this._domNodeEntries.values())
             nodeEntry.initiatedResourceEntries.sort(this._entriesSortComparator);
 
-        this._entries.sort(this._entriesSortComparator);
-
+        this._updateSort();
         this._updateFilteredEntries();
-        this._table.reloadData();
+        this._reloadTable();
     }
 
     // Table delegate
@@ -492,7 +491,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
                 entry.expanded = !entry.expanded;
 
                 this._updateFilteredEntries();
-                this._table.reloadData();
+                this._reloadTable();
             });
 
             createIconElement();
@@ -1057,8 +1056,9 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
         this._pendingFilter = false;
 
-        this._updateSortAndFilteredEntries();
-        this._table.reloadData();
+        this._updateSort();
+        this._updateFilteredEntries();
+        this._reloadTable();
     }
 
     _populateWithInitialResourcesIfNeeded()
@@ -1394,7 +1394,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
             if (this._filteredEntries.lastValue === resourceEntry)
                 this._table.reloadDataAddedToEndOnly();
             else
-                this._table.reloadData();
+                this._reloadTable();
         }
     }
 
@@ -1503,12 +1503,10 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
             && this._passURLFilter(entry);
     }
 
-    _updateSortAndFilteredEntries()
+    _updateSort()
     {
         if (this._entriesSortComparator)
             this._entries = this._entries.sort(this._entriesSortComparator);
-
-        this._updateFilteredEntries();
     }
 
     _updateFilteredEntries()
@@ -1549,12 +1547,16 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
             });
         }
 
-        this._restoreSelectedRow();
-
         this._updateURLFilterActiveIndicator();
         this._updateEmptyFilterResultsMessage();
     }
 
+    _reloadTable()
+    {
+        this._table.reloadData();
+        this._restoreSelectedRow();
+    }
+
     _generateTypeFilter()
     {
         let selectedItems = this._typeFilterScopeBar.selectedItems;
@@ -1583,7 +1585,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         console.assert(!this._hasActiveFilter());
 
         this._updateFilteredEntries();
-        this._table.reloadData();
+        this._reloadTable();
     }
 
     _areFilterListsIdentical(listA, listB)
@@ -1617,7 +1619,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
 
         this._activeTypeFilters = newFilter;
         this._updateFilteredEntries();
-        this._table.reloadData();
+        this._reloadTable();
     }
 
     _handleGroupByDOMNodeCheckedDidChange(event)
@@ -1627,8 +1629,9 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         if (!WI.settings.groupByDOMNode.value)
             this._table.element.classList.remove("grouped");
 
-        this._updateSortAndFilteredEntries();
-        this._table.reloadData();
+        this._updateSort();
+        this._updateFilteredEntries();
+        this._reloadTable();
     }
 
     _urlFilterDidChange(event)
@@ -1648,7 +1651,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
             this._activeURLFilterResources.clear();
 
             this._updateFilteredEntries();
-            this._table.reloadData();
+            this._reloadTable();
             return;
         }
 
@@ -1662,7 +1665,7 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
             this._checkURLFilterAgainstResource(entry.resource);
 
         this._updateFilteredEntries();
-        this._table.reloadData();
+        this._reloadTable();
     }
 
     _restoreSelectedRow()
index 2a5488e..82b3c31 100644 (file)
@@ -237,6 +237,8 @@ WI.Table = class Table extends WI.View
     reloadData()
     {
         this._cachedRows.clear();
+
+        this._selectedRowIndex = NaN;
         this._selectedRows.clear();
 
         this._previousRevealedRowCount = NaN;