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

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

Issue 2609653002: [DevTools] Migrate CallStackSidebarPane to UI.ListControl. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @template T 6 * @template T
7 * @interface 7 * @interface
8 */ 8 */
9 UI.ListDelegate = function() {}; 9 UI.ListDelegate = function() {};
10 10
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 254 }
255 255
256 /** 256 /**
257 * @return {?T} 257 * @return {?T}
258 */ 258 */
259 selectedItem() { 259 selectedItem() {
260 return this._selectedIndex === -1 ? null : this._items[this._selectedIndex]; 260 return this._selectedIndex === -1 ? null : this._items[this._selectedIndex];
261 } 261 }
262 262
263 /** 263 /**
264 * @param {boolean=} canWrap
265 * @param {boolean=} scrollIntoView
266 * @return {boolean}
267 */
268 selectPreviousItem(canWrap, scrollIntoView) {
269 if (this._selectedIndex === -1 && !canWrap)
270 return false;
271 var index = this._selectedIndex === -1 ? this._items.length - 1 : this._sele ctedIndex - 1;
272 index = this._findFirstSelectable(index, -1, !!canWrap);
273 if (index !== -1) {
274 if (scrollIntoView)
275 this.scrollItemAtIndexIntoView(index);
276 this._select(index);
277 return true;
278 }
279 return false;
280 }
281
282 /**
283 * @param {boolean=} canWrap
284 * @param {boolean=} scrollIntoView
285 * @return {boolean}
286 */
287 selectNextItem(canWrap, scrollIntoView) {
288 if (this._selectedIndex === -1 && !canWrap)
289 return false;
290 var index = this._selectedIndex === -1 ? 0 : this._selectedIndex + 1;
291 index = this._findFirstSelectable(index, +1, !!canWrap);
292 if (index !== -1) {
293 if (scrollIntoView)
294 this.scrollItemAtIndexIntoView(index);
295 this._select(index);
296 return true;
297 }
298 return false;
299 }
300
301 /**
264 * @param {!Event} event 302 * @param {!Event} event
265 * @return {boolean} 303 * @return {boolean}
266 */ 304 */
267 onKeyDown(event) { 305 onKeyDown(event) {
268 var index = -1; 306 var index = -1;
269 switch (event.key) { 307 switch (event.key) {
270 case 'ArrowUp': 308 case 'ArrowUp':
271 index = this._selectedIndex === -1 ? this._items.length - 1 : this._sele ctedIndex - 1; 309 return this.selectPreviousItem(true, true);
272 index = this._findFirstSelectable(index, -1, true);
273 break;
274 case 'ArrowDown': 310 case 'ArrowDown':
275 index = this._selectedIndex === -1 ? 0 : this._selectedIndex + 1; 311 return this.selectNextItem(true, true);
276 index = this._findFirstSelectable(index, +1, true);
277 break;
278 case 'PageUp': 312 case 'PageUp':
279 if (this._mode === UI.ListMode.Grow) 313 if (this._mode === UI.ListMode.Grow)
280 return false; 314 return false;
281 index = this._selectedIndex === -1 ? this._items.length - 1 : this._sele ctedIndex; 315 index = this._selectedIndex === -1 ? this._items.length - 1 : this._sele ctedIndex;
282 index = this._findPageSelectable(index, -1); 316 index = this._findPageSelectable(index, -1);
283 break; 317 break;
284 case 'PageDown': 318 case 'PageDown':
285 if (this._mode === UI.ListMode.Grow) 319 if (this._mode === UI.ListMode.Grow)
286 return false; 320 return false;
287 index = this._selectedIndex === -1 ? 0 : this._selectedIndex; 321 index = this._selectedIndex === -1 ? 0 : this._selectedIndex;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 this._firstIndex = firstIndex; 623 this._firstIndex = firstIndex;
590 this._lastIndex = lastIndex; 624 this._lastIndex = lastIndex;
591 this._topHeight = this._offsetAtIndex(firstIndex); 625 this._topHeight = this._offsetAtIndex(firstIndex);
592 this._topElement.style.height = this._topHeight + 'px'; 626 this._topElement.style.height = this._topHeight + 'px';
593 this._bottomHeight = totalHeight - this._offsetAtIndex(lastIndex); 627 this._bottomHeight = totalHeight - this._offsetAtIndex(lastIndex);
594 this._bottomElement.style.height = this._bottomHeight + 'px'; 628 this._bottomElement.style.height = this._bottomHeight + 'px';
595 this._renderedHeight = totalHeight; 629 this._renderedHeight = totalHeight;
596 this.element.scrollTop = scrollTop; 630 this.element.scrollTop = scrollTop;
597 } 631 }
598 }; 632 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698