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

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

Issue 2605253002: [DevTools] Add grow mode to ListControl. (Closed)
Patch Set: addressed review comments 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 * @param {number=} maxItemsHeight 55 * @param {number=} maxItemsHeight
56 * @param {boolean=} captureEnter 56 * @param {boolean=} captureEnter
57 */ 57 */
58 constructor(suggestBoxDelegate, maxItemsHeight, captureEnter) { 58 constructor(suggestBoxDelegate, maxItemsHeight, captureEnter) {
59 this._suggestBoxDelegate = suggestBoxDelegate; 59 this._suggestBoxDelegate = suggestBoxDelegate;
60 this._maxItemsHeight = maxItemsHeight; 60 this._maxItemsHeight = maxItemsHeight;
61 this._maybeHideBound = this._maybeHide.bind(this); 61 this._maybeHideBound = this._maybeHide.bind(this);
62 this._container = createElementWithClass('div', 'suggest-box-container'); 62 this._container = createElementWithClass('div', 'suggest-box-container');
63 this._rowHeight = 17; 63 this._rowHeight = 17;
64 /** @type {!UI.ListControl<!UI.SuggestBox.Suggestion>} */ 64 /** @type {!UI.ListControl<!UI.SuggestBox.Suggestion>} */
65 this._list = new UI.ListControl(this); 65 this._list = new UI.ListControl(this, UI.ListMode.ViewportFixedItems);
66 this._element = this._list.element; 66 this._element = this._list.element;
67 this._element.classList.add('suggest-box'); 67 this._element.classList.add('suggest-box');
68 this._container.appendChild(this._element); 68 this._container.appendChild(this._element);
69 this._element.addEventListener('mousedown', this._onBoxMouseDown.bind(this), true); 69 this._element.addEventListener('mousedown', this._onBoxMouseDown.bind(this), true);
70 this._detailsPopup = this._container.createChild('div', 'suggest-box details -popup monospace'); 70 this._detailsPopup = this._container.createChild('div', 'suggest-box details -popup monospace');
71 this._detailsPopup.classList.add('hidden'); 71 this._detailsPopup.classList.add('hidden');
72 this._asyncDetailsCallback = null; 72 this._asyncDetailsCallback = null;
73 /** @type {!Map<!UI.SuggestBox.Suggestion, !Promise<{detail: string, descrip tion: string}>>} */ 73 /** @type {!Map<!UI.SuggestBox.Suggestion, !Promise<{detail: string, descrip tion: string}>>} */
74 this._asyncDetailsPromises = new Map(); 74 this._asyncDetailsPromises = new Map();
75 this._userInteracted = false; 75 this._userInteracted = false;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 this._asyncDetailsPromises.clear(); 378 this._asyncDetailsPromises.clear();
379 if (asyncDetails) 379 if (asyncDetails)
380 this._asyncDetailsCallback = item => asyncDetails(completions.indexOf(it em)); 380 this._asyncDetailsCallback = item => asyncDetails(completions.indexOf(it em));
381 else 381 else
382 this._asyncDetailsCallback = null; 382 this._asyncDetailsCallback = null;
383 this._userEnteredText = userEnteredText; 383 this._userEnteredText = userEnteredText;
384 384
385 this._show(); 385 this._show();
386 this._updateBoxPosition(anchorBox, completions.length); 386 this._updateBoxPosition(anchorBox, completions.length);
387 this._updateWidth(completions); 387 this._updateWidth(completions);
388 388 this._list.fixedHeightChanged();
389 this._list.setHeightMode(UI.ListHeightMode.Fixed);
390 this._list.replaceAllItems(completions); 389 this._list.replaceAllItems(completions);
391 390
392 var highestPriorityItem = -1; 391 var highestPriorityItem = -1;
393 if (selectHighestPriority) { 392 if (selectHighestPriority) {
394 var highestPriority = -Infinity; 393 var highestPriority = -Infinity;
395 for (var i = 0; i < completions.length; i++) { 394 for (var i = 0; i < completions.length; i++) {
396 var priority = completions[i].priority || 0; 395 var priority = completions[i].priority || 0;
397 if (highestPriority < priority) { 396 if (highestPriority < priority) {
398 highestPriority = priority; 397 highestPriority = priority;
399 highestPriorityItem = i; 398 highestPriorityItem = i;
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 this.element.style.left = containerBox.x + 'px'; 505 this.element.style.left = containerBox.x + 'px';
507 this.element.style.top = containerBox.y + 'px'; 506 this.element.style.top = containerBox.y + 'px';
508 this.element.style.height = containerBox.height + 'px'; 507 this.element.style.height = containerBox.height + 'px';
509 this.element.style.width = containerBox.width + 'px'; 508 this.element.style.width = containerBox.width + 'px';
510 } 509 }
511 510
512 dispose() { 511 dispose() {
513 this.element.remove(); 512 this.element.remove();
514 } 513 }
515 }; 514 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698