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 6635829acc8b174850472b82dd574a23a0ddccd8..844193d221313166a19cb2d8a85699c2a5dd8170 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js |
+++ b/third_party/WebKit/Source/devtools/front_end/ui/ListControl.js |
@@ -261,6 +261,44 @@ UI.ListControl = class { |
} |
/** |
+ * @param {boolean=} canWrap |
+ * @param {boolean=} scrollIntoView |
+ * @return {boolean} |
+ */ |
+ selectPreviousItem(canWrap, scrollIntoView) { |
+ if (this._selectedIndex === -1 && !canWrap) |
+ return false; |
+ var index = this._selectedIndex === -1 ? this._items.length - 1 : this._selectedIndex - 1; |
+ index = this._findFirstSelectable(index, -1, !!canWrap); |
+ if (index !== -1) { |
+ if (scrollIntoView) |
+ this.scrollItemAtIndexIntoView(index); |
+ this._select(index); |
+ return true; |
+ } |
+ return false; |
+ } |
+ |
+ /** |
+ * @param {boolean=} canWrap |
+ * @param {boolean=} scrollIntoView |
+ * @return {boolean} |
+ */ |
+ selectNextItem(canWrap, scrollIntoView) { |
+ if (this._selectedIndex === -1 && !canWrap) |
+ return false; |
+ var index = this._selectedIndex === -1 ? 0 : this._selectedIndex + 1; |
+ index = this._findFirstSelectable(index, +1, !!canWrap); |
+ if (index !== -1) { |
+ if (scrollIntoView) |
+ this.scrollItemAtIndexIntoView(index); |
+ this._select(index); |
+ return true; |
+ } |
+ return false; |
+ } |
+ |
+ /** |
* @param {!Event} event |
* @return {boolean} |
*/ |
@@ -268,13 +306,9 @@ UI.ListControl = class { |
var index = -1; |
switch (event.key) { |
case 'ArrowUp': |
- index = this._selectedIndex === -1 ? this._items.length - 1 : this._selectedIndex - 1; |
- index = this._findFirstSelectable(index, -1, true); |
- break; |
+ return this.selectPreviousItem(true, true); |
case 'ArrowDown': |
- index = this._selectedIndex === -1 ? 0 : this._selectedIndex + 1; |
- index = this._findFirstSelectable(index, +1, true); |
- break; |
+ return this.selectNextItem(true, true); |
case 'PageUp': |
if (this._mode === UI.ListMode.Grow) |
return false; |