Index: third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js b/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js |
index d1f59e3de5d1300df550afe3a9e11dd09f17877f..d46aa33c16537de89ac0bb8d96d4369e384405f6 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js |
+++ b/third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js |
@@ -15,7 +15,6 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
constructor(delegate, promptHistory) { |
super(true); |
this._promptHistory = promptHistory || []; |
- this._renderAsTwoRows = delegate.renderAsTwoRows(); |
this.contentElement.classList.add('filtered-list-widget'); |
this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this), true); |
@@ -54,7 +53,6 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
this._delegate = delegate; |
this._delegate.setRefreshCallback(this._itemsLoaded.bind(this)); |
this._itemsLoaded(); |
- this._updateShowMatchingItems(); |
} |
/** |
@@ -122,7 +120,6 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
this._dialog.setPosition(null, 22); |
this.show(this._dialog.element); |
this._dialog.show(); |
- this._updateShowMatchingItems(); |
} |
/** |
@@ -153,9 +150,7 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
*/ |
_onEnter(event) { |
event.preventDefault(); |
- if (!this._delegate.itemCount()) |
- return; |
- var selectedIndexInDelegate = this._shouldShowMatchingItems() ? this._list.selectedItem() : null; |
+ var selectedIndexInDelegate = this._delegate.itemCount() ? this._list.selectedItem() : null; |
// Detach dialog before allowing delegate to override focus. |
if (this._dialog) |
@@ -181,7 +176,7 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
*/ |
createElementForItem(item) { |
var itemElement = createElement('div'); |
- itemElement.className = 'filtered-list-widget-item ' + (this._renderAsTwoRows ? 'two-rows' : 'one-row'); |
+ itemElement.className = 'filtered-list-widget-item ' + (this._delegate.renderAsTwoRows() ? 'two-rows' : 'one-row'); |
var titleElement = itemElement.createChild('div', 'filtered-list-widget-title'); |
var subtitleElement = itemElement.createChild('div', 'filtered-list-widget-subtitle'); |
subtitleElement.textContent = '\u200B'; |
@@ -234,9 +229,9 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
*/ |
setQuery(query) { |
this._prompt.setText(query); |
+ this._delegate.queryChanged(query); |
this._prompt.autoCompleteSoon(true); |
this._scheduleFilter(); |
- this._updateShowMatchingItems(); |
} |
_tabKeyPressed() { |
@@ -383,26 +378,14 @@ QuickOpen.FilteredListWidget = class extends UI.VBox { |
this._list.element.classList.toggle('hidden', !hasItems); |
this._notFoundElement.classList.toggle('hidden', hasItems); |
if (!hasItems) |
- this._notFoundElement.textContent = this._delegate.notFoundText(); |
- } |
- |
- /** |
- * @return {boolean} |
- */ |
- _shouldShowMatchingItems() { |
- return this._delegate.shouldShowMatchingItems(this._value()); |
+ this._notFoundElement.textContent = this._delegate.notFoundText(this._value()); |
} |
_onInput() { |
- this._updateShowMatchingItems(); |
+ this._delegate.queryChanged(this._value()); |
this._scheduleFilter(); |
} |
- _updateShowMatchingItems() { |
- var shouldShowMatchingItems = this._shouldShowMatchingItems(); |
- this._bottomElementsContainer.classList.toggle('hidden', !shouldShowMatchingItems); |
- } |
- |
/** |
* @param {!Event} event |
*/ |
@@ -463,14 +446,6 @@ QuickOpen.FilteredListWidget.Delegate = class { |
} |
/** |
- * @param {string} query |
- * @return {boolean} |
- */ |
- shouldShowMatchingItems(query) { |
- return true; |
- } |
- |
- /** |
* @return {number} |
*/ |
itemCount() { |
@@ -537,9 +512,16 @@ QuickOpen.FilteredListWidget.Delegate = class { |
} |
/** |
+ * @param {string} query |
+ */ |
+ queryChanged(query) { |
+ } |
+ |
+ /** |
+ * @param {string} query |
* @return {string} |
*/ |
- notFoundText() { |
+ notFoundText(query) { |
return Common.UIString('No results found'); |
} |