Web Inspector: Table should support shift-extending the row selection
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2018 05:13:02 +0000 (05:13 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Nov 2018 05:13:02 +0000 (05:13 +0000)
commit408ccde4bc4873e213db0e7a3d114406d16976e9
treecaf320f51afe9a7cc134f38323c68f7c0902e12e
parent47ba5707de263cc259bf65786438e1f2044e54fe
Web Inspector: Table should support shift-extending the row selection
https://bugs.webkit.org/show_bug.cgi?id=189718
<rdar://problem/44577942>

Reviewed by Devin Rousso.

Source/WebInspectorUI:

Allow the table selection to be extended by shift-clicking a row, or by
holding shift and pressing either the up or down arrow key. If both command
and shift are pressed, shift is ignored. The selection behavior is modeled
after AppKit's NSTableView.

* UserInterface/Base/IndexSet.js:
(WI.IndexSet.prototype.addRange):
(WI.IndexSet.prototype.deleteRange):
(WI.IndexSet.prototype.equals):
(WI.IndexSet.prototype.difference):

* UserInterface/Views/Table.js:
(WI.Table):
(WI.Table.prototype.set allowsMultipleSelection):
(WI.Table.prototype.reloadData):
(WI.Table.prototype.selectRow):
(WI.Table.prototype.deselectRow):
(WI.Table.prototype._handleKeyDown):
Holding shift and pressing either the up or down arrow key extends the
selection to the next unselected row adjacent to the anchor row, or causes
the anchor row to be deselected, decreasing the selection. The table chooses
the action to take based on the direction of movement (up or down), and
the currently selected rows.

(WI.Table.prototype._selectRowsFromArrowKey):
(WI.Table.prototype._handleMouseDown.normalizeRange):
(WI.Table.prototype._handleMouseDown):
Clicking a row while holding down shift extends the selection to include
the rows between the anchor row (exclusive) and clicked row (inclusive).
The anchor row is equal to the value of `_selectedRowIndex` prior to
clicking a new row.

(WI.Table.prototype._deselectAllAndSelect):
(WI.Table.prototype._removeRows):
(WI.Table.prototype._toggleSelectedRowStyle):
(WI.Table.prototype._updateSelectedRows):
Helper method for updating the selection to the specified rows, and updating
DOM styles for rows that are added to or removed from the selection.

LayoutTests:

* inspector/unit-tests/index-set-expected.txt:
* inspector/unit-tests/index-set.html:
Add tests for new IndexSet methods `addRange`, `deleteRange`, `equals`, and `difference`.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238121 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
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