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

Unified Diff: third_party/WebKit/Source/devtools/front_end/quick_open/FilteredListWidget.js

Issue 2679483002: DevTools: Create extensible QuickOpen control (Closed)
Patch Set: rename Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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 be222d573b9dbcbb1037df31651fff56e955ac4f..82311a52c7c1f5f7c109989532d9c04f0f17d38a 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();
}
/**
@@ -123,7 +121,6 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
this._dialog.setContentPosition(null, 22);
this.show(this._dialog.contentElement);
this._dialog.show();
- this._updateShowMatchingItems();
}
/**
@@ -154,9 +151,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)
@@ -182,7 +177,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';
@@ -235,9 +230,9 @@ QuickOpen.FilteredListWidget = class extends UI.VBox {
*/
setQuery(query) {
this._prompt.setText(query);
+ this._delegate.queryChanged(query);
pfeldman 2017/03/02 22:42:27 Seems like a client that has a dialog in hand and
einbinder 2017/03/03 23:07:13 It wasn't the delegate, but now it is so this is g
this._prompt.autoCompleteSoon(true);
this._scheduleFilter();
- this._updateShowMatchingItems();
}
_tabKeyPressed() {
@@ -380,26 +375,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
*/
@@ -460,14 +443,6 @@ QuickOpen.FilteredListWidget.Delegate = class {
}
/**
- * @param {string} query
- * @return {boolean}
- */
- shouldShowMatchingItems(query) {
- return true;
- }
-
- /**
* @return {number}
*/
itemCount() {
@@ -534,9 +509,16 @@ QuickOpen.FilteredListWidget.Delegate = class {
}
/**
+ * @param {string} query
+ */
+ queryChanged(query) {
+ }
+
+ /**
+ * @param {string} query
* @return {string}
*/
- notFoundText() {
+ notFoundText(query) {
return Common.UIString('No results found');
}

Powered by Google App Engine
This is Rietveld 408576698