Web Inspector: Table should support deleting rows
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Oct 2018 23:30:03 +0000 (23:30 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 27 Oct 2018 23:30:03 +0000 (23:30 +0000)
commita249ad555a5b5911044d85431d5aa7cde1f9c992
tree3f66e64ea395569745588913381b89bb7e89f74f
parent45f313160cf91f6b5403649706d73235fd4a988a
Web Inspector: Table should support deleting rows
https://bugs.webkit.org/show_bug.cgi?id=189803
<rdar://problem/44655709>

Reviewed by Devin Rousso.

Source/WebInspectorUI:

Add methods for removing rows from a Table without reloading the data
source. This patch adds Table.prototype.removeRow for removing a single
row, and Table.prototype.removeSelectedRows for removing the entire selection.
The latter also attempts to select a new row, if possible, before removing
the selection.

* UserInterface/Base/IndexSet.js:
(WI.IndexSet.prototype.copy):

* UserInterface/Views/Table.js:
(WI.Table):
(WI.Table.prototype.get numberOfRows):
Cache the number of rows in the table data source. Invalidate cached
value whenever table data is reloaded. Removing rows immediately updates
cached value, without incurring a potentially expensive reload.

(WI.Table.prototype.reloadData):
(WI.Table.prototype.selectRow):
(WI.Table.prototype.deselectRow):
(WI.Table.prototype.removeRow):
(WI.Table.prototype.removeSelectedRows):
Remove the selected rows and select a new row, if possible.
(WI.Table.prototype._updateVisibleRows):
(WI.Table.prototype._handleKeyDown):
(WI.Table.prototype._deselectAllAndSelect):
Drive-by fix: should work when `rowToSelect` isn't already selected.
(WI.Table.prototype._removeRows):
Remove rows and adjust the indexes of rows that are shifted up as a result
of preceding rows being removed.

LayoutTests:

* inspector/table/resources/table-utilities.js:
(TestPage.registerInitializer.InspectorTest.TableDelegate.prototype.tableDidRemoveRows):
(TestPage.registerInitializer.createDataSource):
(TestPage.registerInitializer.InspectorTest.createTable):
(TestPage.registerInitializer.InspectorTest.createTableWithDelegate):
(TestPage.registerInitializer):
Update table test utilities to keep TableDataSource backing array in
sync when rows are removed. Also allow the number of table rows to be
specified when creating a table for testing.

* inspector/table/table-remove-rows-expected.txt: Added.
* inspector/table/table-remove-rows.html: Added.
Add tests for new Table methods `removeRow(rowIndex)` and `removeSelectedRows()`.

* inspector/unit-tests/index-set-expected.txt:
* inspector/unit-tests/index-set.html:
Add tests for new IndexSet method `copy()`.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/inspector/table/resources/table-utilities.js
LayoutTests/inspector/table/table-remove-rows-expected.txt [new file with mode: 0644]
LayoutTests/inspector/table/table-remove-rows.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/index-set-expected.txt
LayoutTests/inspector/unit-tests/index-set.html
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/IndexSet.js
Source/WebInspectorUI/UserInterface/Views/Table.js