Index: third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
index 5c6c6a36a169716665d9c1aa4ad97d67ee6bb24f..7aa04bc627077bebe5fa2df171e612d3319f0e68 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
+++ b/third_party/WebKit/Source/devtools/front_end/sources/UIList.js |
@@ -23,214 +23,191 @@ |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
- |
/** |
- * @constructor |
- * @extends {WebInspector.VBox} |
+ * @unrestricted |
*/ |
-WebInspector.UIList = function() |
-{ |
- WebInspector.VBox.call(this, true); |
- this.registerRequiredCSS("sources/uiList.css"); |
+WebInspector.UIList = class extends WebInspector.VBox { |
+ constructor() { |
+ super(true); |
+ this.registerRequiredCSS('sources/uiList.css'); |
/** @type {!Array.<!WebInspector.UIList.Item>} */ |
this._items = []; |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.UIList.Item} item |
+ * @param {?WebInspector.UIList.Item=} beforeItem |
+ */ |
+ addItem(item, beforeItem) { |
+ item[WebInspector.UIList._Key] = this; |
+ var beforeElement = beforeItem ? beforeItem.element : null; |
+ this.contentElement.insertBefore(item.element, beforeElement); |
+ |
+ var index = beforeItem ? this._items.indexOf(beforeItem) : this._items.length; |
+ console.assert(index >= 0, 'Anchor item not found in UIList'); |
+ this._items.splice(index, 0, item); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.UIList.Item} item |
+ */ |
+ removeItem(item) { |
+ var index = this._items.indexOf(item); |
+ console.assert(index >= 0); |
+ this._items.splice(index, 1); |
+ item.element.remove(); |
+ } |
+ |
+ clear() { |
+ this.contentElement.removeChildren(); |
+ this._items = []; |
+ } |
}; |
-WebInspector.UIList._Key = Symbol("ownerList"); |
- |
-WebInspector.UIList.prototype = { |
- /** |
- * @param {!WebInspector.UIList.Item} item |
- * @param {?WebInspector.UIList.Item=} beforeItem |
- */ |
- addItem: function(item, beforeItem) |
- { |
- item[WebInspector.UIList._Key] = this; |
- var beforeElement = beforeItem ? beforeItem.element : null; |
- this.contentElement.insertBefore(item.element, beforeElement); |
- |
- var index = beforeItem ? this._items.indexOf(beforeItem) : this._items.length; |
- console.assert(index >= 0, "Anchor item not found in UIList"); |
- this._items.splice(index, 0, item); |
- }, |
- |
- /** |
- * @param {!WebInspector.UIList.Item} item |
- */ |
- removeItem: function(item) |
- { |
- var index = this._items.indexOf(item); |
- console.assert(index >= 0); |
- this._items.splice(index, 1); |
- item.element.remove(); |
- }, |
- |
- clear: function() |
- { |
- this.contentElement.removeChildren(); |
- this._items = []; |
- }, |
- |
- __proto__: WebInspector.VBox.prototype |
-}; |
+WebInspector.UIList._Key = Symbol('ownerList'); |
/** |
- * @constructor |
- * @param {string} title |
- * @param {string} subtitle |
- * @param {boolean=} isLabel |
+ * @unrestricted |
*/ |
-WebInspector.UIList.Item = function(title, subtitle, isLabel) |
-{ |
- this.element = createElementWithClass("div", "list-item"); |
+WebInspector.UIList.Item = class { |
+ /** |
+ * @param {string} title |
+ * @param {string} subtitle |
+ * @param {boolean=} isLabel |
+ */ |
+ constructor(title, subtitle, isLabel) { |
+ this.element = createElementWithClass('div', 'list-item'); |
if (isLabel) |
- this.element.classList.add("label"); |
+ this.element.classList.add('label'); |
- this.titleElement = this.element.createChild("div", "title"); |
- this.subtitleElement = this.element.createChild("div", "subtitle"); |
+ this.titleElement = this.element.createChild('div', 'title'); |
+ this.subtitleElement = this.element.createChild('div', 'subtitle'); |
this._hidden = false; |
this._isLabel = !!isLabel; |
this.setTitle(title); |
this.setSubtitle(subtitle); |
this.setSelected(false); |
-}; |
- |
-WebInspector.UIList.Item.prototype = { |
- /** |
- * @return {?WebInspector.UIList.Item} |
- */ |
- nextSibling: function() |
- { |
- var list = this[WebInspector.UIList._Key]; |
- var index = list._items.indexOf(this); |
- console.assert(index >= 0); |
- return list._items[index + 1] || null; |
- }, |
- |
- /** |
- * @return {string} |
- */ |
- title: function() |
- { |
- return this._title; |
- }, |
- |
- /** |
- * @param {string} x |
- */ |
- setTitle: function(x) |
- { |
- if (this._title === x) |
- return; |
- this._title = x; |
- this.titleElement.textContent = x; |
- }, |
- |
- /** |
- * @return {string} |
- */ |
- subtitle: function() |
- { |
- return this._subtitle; |
- }, |
- |
- /** |
- * @param {string} x |
- */ |
- setSubtitle: function(x) |
- { |
- if (this._subtitle === x) |
- return; |
- this._subtitle = x; |
- this.subtitleElement.textContent = x; |
- }, |
- |
- /** |
- * @return {boolean} |
- */ |
- isSelected: function() |
- { |
- return this._selected; |
- }, |
- |
- /** |
- * @param {boolean} x |
- */ |
- setSelected: function(x) |
- { |
- if (x) |
- this.select(); |
- else |
- this.deselect(); |
- }, |
- |
- select: function() |
- { |
- if (this._selected) |
- return; |
- this._selected = true; |
- this.element.classList.add("selected"); |
- }, |
- |
- deselect: function() |
- { |
- if (!this._selected) |
- return; |
- this._selected = false; |
- this.element.classList.remove("selected"); |
- }, |
- |
- toggleSelected: function() |
- { |
- this.setSelected(!this.isSelected()); |
- }, |
- |
- /** |
- * @return {boolean} |
- */ |
- isHidden: function() |
- { |
- return this._hidden; |
- }, |
- |
- /** |
- * @param {boolean} x |
- */ |
- setHidden: function(x) |
- { |
- if (this._hidden === x) |
- return; |
- this._hidden = x; |
- this.element.classList.toggle("hidden", x); |
- }, |
- |
- /** |
- * @return {boolean} |
- */ |
- isLabel: function() |
- { |
- return this._isLabel; |
- }, |
- |
- /** |
- * @param {boolean} x |
- */ |
- setDimmed: function(x) |
- { |
- this.element.classList.toggle("dimmed", x); |
- }, |
- |
- discard: function() |
- { |
- }, |
- |
- /** |
- * @param {boolean} hoverable |
- */ |
- setHoverable: function(hoverable) |
- { |
- this.element.classList.toggle("ignore-hover", !hoverable); |
- }, |
+ } |
+ |
+ /** |
+ * @return {?WebInspector.UIList.Item} |
+ */ |
+ nextSibling() { |
+ var list = this[WebInspector.UIList._Key]; |
+ var index = list._items.indexOf(this); |
+ console.assert(index >= 0); |
+ return list._items[index + 1] || null; |
+ } |
+ |
+ /** |
+ * @return {string} |
+ */ |
+ title() { |
+ return this._title; |
+ } |
+ |
+ /** |
+ * @param {string} x |
+ */ |
+ setTitle(x) { |
+ if (this._title === x) |
+ return; |
+ this._title = x; |
+ this.titleElement.textContent = x; |
+ } |
+ |
+ /** |
+ * @return {string} |
+ */ |
+ subtitle() { |
+ return this._subtitle; |
+ } |
+ |
+ /** |
+ * @param {string} x |
+ */ |
+ setSubtitle(x) { |
+ if (this._subtitle === x) |
+ return; |
+ this._subtitle = x; |
+ this.subtitleElement.textContent = x; |
+ } |
+ |
+ /** |
+ * @return {boolean} |
+ */ |
+ isSelected() { |
+ return this._selected; |
+ } |
+ |
+ /** |
+ * @param {boolean} x |
+ */ |
+ setSelected(x) { |
+ if (x) |
+ this.select(); |
+ else |
+ this.deselect(); |
+ } |
+ |
+ select() { |
+ if (this._selected) |
+ return; |
+ this._selected = true; |
+ this.element.classList.add('selected'); |
+ } |
+ |
+ deselect() { |
+ if (!this._selected) |
+ return; |
+ this._selected = false; |
+ this.element.classList.remove('selected'); |
+ } |
+ |
+ toggleSelected() { |
+ this.setSelected(!this.isSelected()); |
+ } |
+ |
+ /** |
+ * @return {boolean} |
+ */ |
+ isHidden() { |
+ return this._hidden; |
+ } |
+ |
+ /** |
+ * @param {boolean} x |
+ */ |
+ setHidden(x) { |
+ if (this._hidden === x) |
+ return; |
+ this._hidden = x; |
+ this.element.classList.toggle('hidden', x); |
+ } |
+ |
+ /** |
+ * @return {boolean} |
+ */ |
+ isLabel() { |
+ return this._isLabel; |
+ } |
+ |
+ /** |
+ * @param {boolean} x |
+ */ |
+ setDimmed(x) { |
+ this.element.classList.toggle('dimmed', x); |
+ } |
+ |
+ discard() { |
+ } |
+ |
+ /** |
+ * @param {boolean} hoverable |
+ */ |
+ setHoverable(hoverable) { |
+ this.element.classList.toggle('ignore-hover', !hoverable); |
+ } |
}; |