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

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

Issue 2609653002: [DevTools] Migrate CallStackSidebarPane to UI.ListControl. (Closed)
Patch Set: Created 4 years 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 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;

Powered by Google App Engine
This is Rietveld 408576698