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

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

Issue 2557763003: DevTools: sort completions by prototype. (Closed)
Patch Set: rebaselined 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/SuggestBox.js
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
index cc55b44f5de00918f8cc4246ec0a2215f70e2991..98960a8fed99d165a76a8a9c40132cd84aed2216 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/SuggestBox.js
@@ -271,12 +271,13 @@ UI.SuggestBox = class {
/**
* @param {string} query
- * @param {string} text
+ * @param {string} title
+ * @param {string=} subtitle
* @param {string=} iconType
* @param {boolean=} isSecondary
* @return {!Element}
*/
- _createItemElement(query, text, iconType, isSecondary) {
+ _createItemElement(query, title, subtitle, iconType, isSecondary) {
var element = createElementWithClass('div', 'suggest-box-content-item source-code');
if (iconType) {
var icon = UI.Icon.create(iconType, 'suggestion-icon');
@@ -285,17 +286,21 @@ UI.SuggestBox = class {
if (isSecondary)
element.classList.add('secondary');
element.tabIndex = -1;
- var displayText = text.trimEnd(50 + query.length);
+ var displayText = title.trimEnd(50 + query.length);
- var suggestionText = element.createChild('span', 'suggestion-text');
+ var titleElement = element.createChild('span', 'suggestion-title');
var index = displayText.toLowerCase().indexOf(query.toLowerCase());
if (index > 0)
- suggestionText.createChild('span').textContent = displayText.substring(0, index);
+ titleElement.createChild('span').textContent = displayText.substring(0, index);
if (index > -1)
- suggestionText.createChild('span', 'query').textContent = displayText.substring(index, index + query.length);
- suggestionText.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0);
- suggestionText.createChild('span', 'spacer');
- element.__fullValue = text;
+ titleElement.createChild('span', 'query').textContent = displayText.substring(index, index + query.length);
+ titleElement.createChild('span').textContent = displayText.substring(index > -1 ? index + query.length : 0);
+ titleElement.createChild('span', 'spacer');
+ if (subtitle) {
+ var subtitleElement = element.createChild('span', 'suggestion-subtitle');
+ subtitleElement.textContent = subtitle.trimEnd(15);
+ }
+ element.__fullValue = title;
element.addEventListener('mousedown', this._onItemMouseDown.bind(this), false);
return element;
}
@@ -536,14 +541,15 @@ UI.SuggestBox = class {
itemElement(index) {
if (!this._elementList[index]) {
this._elementList[index] = this._createItemElement(
- this._userEnteredText, this._items[index].title, this._items[index].iconType, this._items[index].isSecondary);
+ this._userEnteredText, this._items[index].title, this._items[index].subtitle, this._items[index].iconType,
+ this._items[index].isSecondary);
}
return this._elementList[index];
}
};
/**
- * @typedef {!Array.<{title: string, iconType: (string|undefined), priority: (number|undefined), isSecondary: (boolean|undefined)}>}
+ * @typedef {!Array.<{title: string, subtitle: (string|undefined), iconType: (string|undefined), priority: (number|undefined), isSecondary: (boolean|undefined)}>}
*/
UI.SuggestBox.Suggestions;

Powered by Google App Engine
This is Rietveld 408576698