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

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

Issue 2749363002: DevTools: greyed-out console suggestion should not clash with console history (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui/suggestBox.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 * @param {number=} maxItemsHeight 54 * @param {number=} maxItemsHeight
55 * @param {boolean=} captureEnter 55 * @param {boolean=} captureEnter
56 */ 56 */
57 constructor(suggestBoxDelegate, maxItemsHeight, captureEnter) { 57 constructor(suggestBoxDelegate, maxItemsHeight, captureEnter) {
58 this._suggestBoxDelegate = suggestBoxDelegate; 58 this._suggestBoxDelegate = suggestBoxDelegate;
59 this._maxItemsHeight = maxItemsHeight; 59 this._maxItemsHeight = maxItemsHeight;
60 this._captureEnter = captureEnter; 60 this._captureEnter = captureEnter;
61 this._rowHeight = 17; 61 this._rowHeight = 17;
62 this._userInteracted = false; 62 this._userInteracted = false;
63 this._userEnteredText = ''; 63 this._userEnteredText = '';
64 this._defaultSelectionIsDimmed = false;
65
64 /** @type {?string} */ 66 /** @type {?string} */
65 this._onlyCompletion = null; 67 this._onlyCompletion = null;
66 68
67 /** @type {!UI.ListControl<!UI.SuggestBox.Suggestion>} */ 69 /** @type {!UI.ListControl<!UI.SuggestBox.Suggestion>} */
68 this._list = new UI.ListControl(this, UI.ListMode.EqualHeightItems); 70 this._list = new UI.ListControl(this, UI.ListMode.EqualHeightItems);
69 this._element = this._list.element; 71 this._element = this._list.element;
70 this._element.classList.add('suggest-box'); 72 this._element.classList.add('suggest-box');
71 this._element.addEventListener('mousedown', event => event.preventDefault(), true); 73 this._element.addEventListener('mousedown', event => event.preventDefault(), true);
72 74
73 this._glassPane = new UI.GlassPane(); 75 this._glassPane = new UI.GlassPane();
74 this._glassPane.setAnchorBehavior(UI.GlassPane.AnchorBehavior.PreferBottom); 76 this._glassPane.setAnchorBehavior(UI.GlassPane.AnchorBehavior.PreferBottom);
75 this._glassPane.setSetOutsideClickCallback(this.hide.bind(this)); 77 this._glassPane.setSetOutsideClickCallback(this.hide.bind(this));
76 var shadowRoot = UI.createShadowRootWithCoreStyles(this._glassPane.contentEl ement, 'ui/suggestBox.css'); 78 var shadowRoot = UI.createShadowRootWithCoreStyles(this._glassPane.contentEl ement, 'ui/suggestBox.css');
77 shadowRoot.appendChild(this._element); 79 shadowRoot.appendChild(this._element);
78 } 80 }
79 81
80 /** 82 /**
81 * @param {boolean} value 83 * @param {boolean} value
82 */ 84 */
83 setDefaultSelectionIsDimmed(value) { 85 setDefaultSelectionIsDimmed(value) {
86 this._defaultSelectionIsDimmed = value;
84 this._element.classList.toggle('default-selection-is-dimmed', value); 87 this._element.classList.toggle('default-selection-is-dimmed', value);
85 } 88 }
86 89
87 /** 90 /**
88 * @param {boolean} value 91 * @param {boolean} value
89 */ 92 */
90 _setUserInteracted(value) { 93 _setUserInteracted(value) {
91 this._userInteracted = value; 94 this._userInteracted = value;
92 this._element.classList.toggle('user-has-interacted', value); 95 this._element.classList.toggle('user-has-interacted', value);
93 } 96 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 /** 255 /**
253 * @override 256 * @override
254 * @param {?UI.SuggestBox.Suggestion} from 257 * @param {?UI.SuggestBox.Suggestion} from
255 * @param {?UI.SuggestBox.Suggestion} to 258 * @param {?UI.SuggestBox.Suggestion} to
256 * @param {?Element} fromElement 259 * @param {?Element} fromElement
257 * @param {?Element} toElement 260 * @param {?Element} toElement
258 */ 261 */
259 selectedItemChanged(from, to, fromElement, toElement) { 262 selectedItemChanged(from, to, fromElement, toElement) {
260 if (fromElement) 263 if (fromElement)
261 fromElement.classList.remove('selected', 'force-white-icons'); 264 fromElement.classList.remove('selected', 'force-white-icons');
262 if (toElement) 265 if (toElement) {
263 toElement.classList.add('selected', 'force-white-icons'); 266 toElement.classList.add('selected');
267 if (fromElement || this._userInteracted || !this._defaultSelectionIsDimmed )
dgozman 2017/03/15 21:17:43 Why check for |fromElement|?
lushnikov 2017/03/16 08:25:46 In this case the _userInteracted is not yet update
268 toElement.classList.add('force-white-icons');
269 }
264 if (!to) 270 if (!to)
265 return; 271 return;
266 this._applySuggestion(true); 272 this._applySuggestion(true);
267 } 273 }
268 274
269 /** 275 /**
270 * @param {!UI.SuggestBox.Suggestions} completions 276 * @param {!UI.SuggestBox.Suggestions} completions
271 * @param {boolean} canShowForSingleItem 277 * @param {boolean} canShowForSingleItem
272 * @param {string} userEnteredText 278 * @param {string} userEnteredText
273 * @return {boolean} 279 * @return {boolean}
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 380
375 /** 381 /**
376 * @typedef {!{text: string, subtitle: (string|undefined), iconType: (string|und efined), priority: (number|undefined), isSecondary: (boolean|undefined), title: (string|undefined)}} 382 * @typedef {!{text: string, subtitle: (string|undefined), iconType: (string|und efined), priority: (number|undefined), isSecondary: (boolean|undefined), title: (string|undefined)}}
377 */ 383 */
378 UI.SuggestBox.Suggestion; 384 UI.SuggestBox.Suggestion;
379 385
380 /** 386 /**
381 * @typedef {!Array<!UI.SuggestBox.Suggestion>} 387 * @typedef {!Array<!UI.SuggestBox.Suggestion>}
382 */ 388 */
383 UI.SuggestBox.Suggestions; 389 UI.SuggestBox.Suggestions;
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui/suggestBox.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698