| Index: chrome/browser/resources/shared/js/cr/ui/list_single_selection_model.js
|
| diff --git a/chrome/browser/resources/shared/js/cr/ui/list_single_selection_model.js b/chrome/browser/resources/shared/js/cr/ui/list_single_selection_model.js
|
| index 119f0fb6d4e3a6de354feb03c6ed9d6e6298a72e..2cf43a92ca9b9c88dc1759590cde51313316eb6a 100644
|
| --- a/chrome/browser/resources/shared/js/cr/ui/list_single_selection_model.js
|
| +++ b/chrome/browser/resources/shared/js/cr/ui/list_single_selection_model.js
|
| @@ -197,35 +197,21 @@ cr.define('cr.ui', function() {
|
| * @param {!Array.<number>} permutation The reordering permutation.
|
| */
|
| adjustToReordering: function(permutation) {
|
| + if (this.leadIndex != -1)
|
| + this.leadIndex = permutation[this.leadIndex];
|
| +
|
| + var oldSelectedIndex = this.selectedIndex;
|
| + if (oldSelectedIndex != -1) {
|
| + this.selectedIndex = permutation[oldSelectedIndex];
|
| + }
|
| },
|
|
|
| /**
|
| - * Adjust the selection by adding or removing a certain numbers of items.
|
| - * This should be called by the owner of the selection model as items are
|
| - * added and removed from the underlying data model.
|
| - * @param {number} index The index of the first change.
|
| - * @param {number} itemsRemoved Number of items removed.
|
| - * @param {number} itemsAdded Number of items added.
|
| + * Adjusts selection model length.
|
| + * @param {number} length New selection model length.
|
| */
|
| - adjust: function(index, itemsRemoved, itemsAdded) {
|
| - function getNewAdjustedIndex(i) {
|
| - if (i >= index && i < index + itemsRemoved) {
|
| - return index;
|
| - } else if (i >= index) {
|
| - return i + itemsAdded - itemsRemoved;
|
| - }
|
| - return i;
|
| - }
|
| -
|
| - this.length_ += itemsAdded - itemsRemoved;
|
| -
|
| - var i = this.selectedIndex;
|
| - if (itemsRemoved > 0 && i >= index && i < index + itemsRemoved)
|
| - this.selectedIndex = -1;
|
| - else if (i >= index)
|
| - this.selectedIndex = i + itemsAdded - itemsRemoved;
|
| -
|
| - this.leadIndex = getNewAdjustedIndex(this.leadIndex);
|
| + adjustLength: function(length) {
|
| + this.length_ = length;
|
| }
|
| };
|
|
|
|
|