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

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

Issue 2609653002: [DevTools] Migrate CallStackSidebarPane to UI.ListControl. (Closed)
Patch Set: comments addressed, more fixes Created 3 years, 11 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 f05dd175e1590738a337c1778b898641b80a4dbc..532a4d8d9110b10953685fa6320e036eb3937a04 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js
@@ -200,10 +200,15 @@ UI.ListControl = class {
}
/**
- * @param {!Element} element
+ * @param {?Node} node
* @return {?T}
*/
- itemForElement(element) {
+ itemForNode(node) {
+ while (node && node.parentNodeOrShadowHost() !== this.element)
+ node = node.parentNodeOrShadowHost();
+ if (!node)
+ return null;
+ var element = /** @type {!Element} */ (node);
var index = this._items.findIndex(item => this._itemToElement.get(item) === element);
return index !== -1 ? this._items[index] : null;
}
@@ -344,14 +349,8 @@ UI.ListControl = class {
* @param {!Event} event
*/
_onClick(event) {
- var node = event.target;
- while (node && node.parentNodeOrShadowHost() !== this.element)
- node = node.parentNodeOrShadowHost();
- if (!node)
- return;
- var element = /** @type {!Element} */ (node);
- var item = this.itemForElement(element);
- if (item)
+ var item = this.itemForNode(/** @type {?Node} */ (event.target));
+ if (item && this._delegate.isItemSelectable(item))
this.selectItem(item);
}

Powered by Google App Engine
This is Rietveld 408576698