Fixes possible crash in TableView
commitdef5587881b9878e1b8bb6491db2fc977a7e76f3
authorsky <sky@chromium.org>
Thu, 14 May 2015 15:10:51 +0000 (14 08:10 -0700)
committerCommit bot <commit-bot@chromium.org>
Thu, 14 May 2015 15:11:06 +0000 (14 15:11 +0000)
tree45e71e318e7d5fe512c4a07aa0d2a92641f3d0d9
parentb4e2a3bbaabf98abf089396e7ce375b58fa8dfcd
Fixes possible crash in TableView

The sequence leading to the crash is:
. Enable sorting.
. Have more than one selected row.
. Remove one of the selected rows. The removed row must also contain
  the anchor.
. Focus the table.

The crash happened because we tried to get the view index for -1.

In general the anchor shouldn't be -1 if there is at least one item in
the selection. The only place anchor could be -1 and there is a
selection is during removal. This patch fixes that.

BUG=480296
TEST=covered by test now.
R=sadrul@chromium.org

Review URL: https://codereview.chromium.org/1129233006

Cr-Commit-Position: refs/heads/master@{#329853}
ui/views/controls/table/table_view.cc
ui/views/controls/table/table_view_unittest.cc