[WIP] Keyboard shortcuts for expand & collapse diff

Review Request #10951 — Created March 12, 2020 and updated — Latest diff uploaded


Review Board


This patch adds keyboard shortcuts to expand & collapse the diff in a review
request and in a diff fragment in a review. Expand is triggered by the e
key and collapse is triggered by the w key (the c key may seem more
natural, but it's taken already by another shortcut so w was chosen for its
proximity to the e key for ease of use between them).

For the diff viewer, expand and collapse buttons are now tracked as anchors
in RB.DiffViewerPageView. This allows us to find the next button on the
page from the currently selected anchor and trigger it when a keyboard
shortcut is used. The e and w keys are added to the existing key
bindings mixin object to track those key presses and trigger the right

For diff fragments, there can only be one set of expand buttons and one
collapse button in any given fragment. If the fragment is focused, the e
and w keys will trigger their respective expand and collapse buttons. This
is implemented by using the key bindings mixin in RB.DiffFragmentView. The
shortcut to expand the fragment defaults to expanding the diff by 20 lines,
which is achieved by adding a modifier to desired expand button.

Manual testing & unit tests for the e and w key events in both the diff
fragment and diff viewer.