Web Inspector: Table should support multiple selection and Cmd-click behavior
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2018 21:54:14 +0000 (21:54 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Oct 2018 21:54:14 +0000 (21:54 +0000)
commitfb7d72ce50ecd13dad46a94702f5f3f5d1b48460
tree3045f4179a41e3a06bd863055185ed0b1063b8ab
parent9feab99d808a1e6dcae509c29e8074027cd427cb
Web Inspector: Table should support multiple selection and Cmd-click behavior
https://bugs.webkit.org/show_bug.cgi?id=189705
<rdar://problem/44571170>

Reviewed by Devin Rousso.

Source/WebInspectorUI:

Add multiple row selection to Table, with new methods for programmatic
selection (deselectRow, deselectAll), and Command-click support for
selecting/deselecting Table rows.

* UserInterface/Base/IndexSet.js: Added.
(WI.IndexSet):
(WI.IndexSet.prototype.get size):
(WI.IndexSet.prototype.get firstIndex):
(WI.IndexSet.prototype.get lastIndex):
(WI.IndexSet.prototype.add):
(WI.IndexSet.prototype.delete):
(WI.IndexSet.prototype.has):
(WI.IndexSet.prototype.clear):
(WI.IndexSet.prototype.indexGreaterThan):
(WI.IndexSet.prototype.indexLessThan):
(WI.IndexSet.prototype.Symbol.iterator):
(WI.IndexSet.prototype._indexClosestTo):
(WI.IndexSet.prototype._validateIndex):
Helper container for managing an ordered sequence of unique positive
integers, with set semantics, backed by a sorted array. Used by Table,
and eventually by TreeOutline.

* UserInterface/Main.html:
* UserInterface/Test.html:
* UserInterface/Test/Test.js:
New files and stubs to make Table layout tests possible.

* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.prototype.reset):
(WI.NetworkTableContentView.prototype.showRepresentedObject):
(WI.NetworkTableContentView.prototype.networkResourceDetailViewClose):
(WI.NetworkTableContentView.prototype.tableSelectionDidChange):
(WI.NetworkTableContentView.prototype._restoreSelectedRow):
(WI.NetworkTableContentView.prototype.tableSelectedRowChanged): Deleted.
Replace uses of `clearSelectedRow` with `deselectAll`, and updated
selection changed delegate.

* UserInterface/Views/Table.css:
(.table > .data-container > .data-list > li):
(.table > .data-container > .data-list > li.selected):
(@media (prefers-dark-interface)):
(.table,): Deleted.
Removed styles that are no longer needed after https://webkit.org/b/189766,
and provide a visual separation between adjacent selected rows.

* UserInterface/Views/Table.js:
(WI.Table):
(WI.Table.prototype.get selectedRows):
(WI.Table.prototype.get allowsMultipleSelection):
(WI.Table.prototype.set allowsMultipleSelection):
(WI.Table.prototype.reloadData):
(WI.Table.prototype.selectRow):
(WI.Table.prototype.deselectRow):
(WI.Table.prototype.deselectAll):
(WI.Table.prototype._getOrCreateRow):
(WI.Table.prototype._handleMouseDown):
(WI.Table.prototype._deselectAllAndSelect):
(WI.Table.prototype._isRowSelected):
(WI.Table.prototype._notifySelectionDidChange):
(WI.Table.prototype.clearSelectedRow): Deleted.
Table now tracks selected rows using an IndexSet. selectRow accepts an
optional parameter, `extendSelection`, for adding rows to the selection.
_selectedRowIndex is now used to track the most recently selected row.
This will be the only selected row unless multiple selection is enabled,
in which case it is the row that has the "focus", for purposes of selecting
a new row using the up or down arrow keys.

LayoutTests:

* inspector/table/resources/table-utilities.js: Added.
(TestPage.registerInitializer.InspectorTest.TableDataSource):
(TestPage.registerInitializer.InspectorTest.TableDataSource.prototype.get items):
(TestPage.registerInitializer.InspectorTest.TableDataSource.prototype.tableNumberOfRows):
(TestPage.registerInitializer.InspectorTest.TableDelegate):
(TestPage.registerInitializer.InspectorTest.TableDelegate.prototype.tableSelectionDidChange):
(TestPage.registerInitializer.InspectorTest.TableDelegate.prototype.tablePopulateCell):
(TestPage.registerInitializer.InspectorTest.createTable):
(TestPage.registerInitializer):

* inspector/table/table-selection-expected.txt: Added.
* inspector/table/table-selection.html: Added.
* inspector/unit-tests/index-set-expected.txt: Added.
* inspector/unit-tests/index-set.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/table/resources/table-utilities.js [new file with mode: 0644]
LayoutTests/inspector/table/table-selection-expected.txt [new file with mode: 0644]
LayoutTests/inspector/table/table-selection.html [new file with mode: 0644]
LayoutTests/inspector/unit-tests/index-set-expected.txt [new file with mode: 0644]
LayoutTests/inspector/unit-tests/index-set.html [new file with mode: 0644]
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/IndexSet.js [new file with mode: 0644]
Source/WebInspectorUI/UserInterface/Main.html
Source/WebInspectorUI/UserInterface/Test.html
Source/WebInspectorUI/UserInterface/Test/Test.js
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
Source/WebInspectorUI/UserInterface/Views/Table.css
Source/WebInspectorUI/UserInterface/Views/Table.js