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

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: 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 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (this._mode !== UI.ListMode.EqualHeightItems) 193 if (this._mode !== UI.ListMode.EqualHeightItems)
194 throw 'Only supported in equal height items mode'; 194 throw 'Only supported in equal height items mode';
195 this._fixedHeight = 0; 195 this._fixedHeight = 0;
196 if (this._items.length) { 196 if (this._items.length) {
197 this._itemToElement.clear(); 197 this._itemToElement.clear();
198 this._invalidate(0, this._items.length, this._items.length); 198 this._invalidate(0, this._items.length, this._items.length);
199 } 199 }
200 } 200 }
201 201
202 /** 202 /**
203 * @param {!Element} element 203 * @param {?Node} node
204 * @return {?T} 204 * @return {?T}
205 */ 205 */
206 itemForElement(element) { 206 itemForNode(node) {
207 while (node && node.parentNodeOrShadowHost() !== this.element)
208 node = node.parentNodeOrShadowHost();
209 if (!node)
210 return null;
211 var element = /** @type {!Element} */ (node);
207 var index = this._items.findIndex(item => this._itemToElement.get(item) === element); 212 var index = this._items.findIndex(item => this._itemToElement.get(item) === element);
208 return index !== -1 ? this._items[index] : null; 213 return index !== -1 ? this._items[index] : null;
209 } 214 }
210 215
211 /** 216 /**
212 * @param {T} item 217 * @param {T} item
213 * @param {boolean=} center 218 * @param {boolean=} center
214 */ 219 */
215 scrollItemIntoView(item, center) { 220 scrollItemIntoView(item, center) {
216 var index = this._items.indexOf(item); 221 var index = this._items.indexOf(item);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 if (top < scrollTop) 342 if (top < scrollTop)
338 this._updateViewport(top, viewportHeight); 343 this._updateViewport(top, viewportHeight);
339 else if (bottom > scrollTop + viewportHeight) 344 else if (bottom > scrollTop + viewportHeight)
340 this._updateViewport(bottom - viewportHeight, viewportHeight); 345 this._updateViewport(bottom - viewportHeight, viewportHeight);
341 } 346 }
342 347
343 /** 348 /**
344 * @param {!Event} event 349 * @param {!Event} event
345 */ 350 */
346 _onClick(event) { 351 _onClick(event) {
347 var node = event.target; 352 var item = this.itemForNode(/** @type {?Node} */ (event.target));
348 while (node && node.parentNodeOrShadowHost() !== this.element) 353 if (item && this._delegate.isItemSelectable(item))
349 node = node.parentNodeOrShadowHost();
350 if (!node)
351 return;
352 var element = /** @type {!Element} */ (node);
353 var item = this.itemForElement(element);
354 if (item)
355 this.selectItem(item); 354 this.selectItem(item);
356 } 355 }
357 356
358 /** 357 /**
359 * @param {!Event} event 358 * @param {!Event} event
360 */ 359 */
361 _onKeyDown(event) { 360 _onKeyDown(event) {
362 var selected = false; 361 var selected = false;
363 switch (event.key) { 362 switch (event.key) {
364 case 'ArrowUp': 363 case 'ArrowUp':
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 this._firstIndex = firstIndex; 650 this._firstIndex = firstIndex;
652 this._lastIndex = lastIndex; 651 this._lastIndex = lastIndex;
653 this._topHeight = this._offsetAtIndex(firstIndex); 652 this._topHeight = this._offsetAtIndex(firstIndex);
654 this._topElement.style.height = this._topHeight + 'px'; 653 this._topElement.style.height = this._topHeight + 'px';
655 this._bottomHeight = totalHeight - this._offsetAtIndex(lastIndex); 654 this._bottomHeight = totalHeight - this._offsetAtIndex(lastIndex);
656 this._bottomElement.style.height = this._bottomHeight + 'px'; 655 this._bottomElement.style.height = this._bottomHeight + 'px';
657 this._renderedHeight = totalHeight; 656 this._renderedHeight = totalHeight;
658 this.element.scrollTop = scrollTop; 657 this.element.scrollTop = scrollTop;
659 } 658 }
660 }; 659 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698