Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/ui/ListControl.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js b/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js |
| index b55c2034cdfbfaaa3619d0e399d2c49445532b4f..c89148cb5b1c366205b0773e79545c67c4d71655 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js |
| @@ -123,6 +123,23 @@ UI.ListControl = class { |
| this.replaceItemsInRange(index, index, [item]); |
| } |
| + /** |
| + * @param {T} item |
| + * @param {function(T, T):number} comparator |
| + */ |
| + insertItemWithComparator(item, comparator) { |
| + var index = this._items.lowerBound(item, comparator); |
| + this.insertItemAtIndex(index, item); |
| + } |
| + |
| + /** |
| + * @param {T} item |
| + * @return {boolean} |
| + */ |
| + includes(item) { |
|
dgozman
2017/05/09 23:11:12
Let's do indexOfItem instead.
einbinder
2017/05/11 00:07:03
Done.
|
| + return this._items.includes(item); |
| + } |
| + |
| /** |
| * @param {number} index |
| * @return {T} |
| @@ -181,6 +198,22 @@ UI.ListControl = class { |
| this.replaceItemsInRange(0, this._items.length, items); |
| } |
| + refreshAllItems() { |
| + this.refreshItemsInRange(0, this._items.length); |
| + } |
| + |
| + /** |
| + * @param {number} from |
| + * @param {number} to |
| + */ |
| + refreshItemsInRange(from, to) { |
| + for (var i = from; i < to; i++) |
| + this._itemToElement.delete(this._items[i]); |
| + this.invalidateRange(from, to); |
| + if (this._selectedIndex !== -1) |
| + this._select(this._selectedIndex, null, null); |
| + } |
| + |
| /** |
| * @param {number} from |
| * @param {number} to |
| @@ -241,11 +274,19 @@ UI.ListControl = class { |
| return this._selectedIndex === -1 ? null : this._items[this._selectedIndex]; |
| } |
| + /** |
| + * @return {number} |
| + */ |
| + selectedIndex() { |
| + return this._selectedIndex; |
| + } |
| + |
| /** |
| * @param {?T} item |
| * @param {boolean=} center |
| + * @param {boolean=} dontScroll |
| */ |
| - selectItem(item, center) { |
| + selectItem(item, center, dontScroll) { |
| var index = -1; |
| if (item !== null) { |
| index = this._items.indexOf(item); |
| @@ -256,7 +297,7 @@ UI.ListControl = class { |
| } |
| if (this._selectedIndex !== index) |
| this._select(index); |
| - if (index !== -1) |
| + if (index !== -1 && !dontScroll) |
| this._scrollIntoView(index, center); |
| } |