Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: third_party/WebKit/Source/devtools/front_end/ui/ListControl.js

Issue 2842843003: DevTools: Display product information in ConsoleContextSelector (Closed)
Patch Set: 2 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
}

Powered by Google App Engine
This is Rietveld 408576698