Commit 97f65bcb authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: make search in sources show up in drawer again.

Change-Id: Ib2a034a4ee2b38ced8e1dc51247a49eee244aede
Reviewed-on: https://chromium-review.googlesource.com/991152
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Reviewed-by: default avatarJoel Einbinder <einbinder@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548231}
parent 5cec364d
...@@ -35,16 +35,27 @@ Search.SearchView = class extends UI.VBox { ...@@ -35,16 +35,27 @@ Search.SearchView = class extends UI.VBox {
this._searchPanelElement = this.contentElement.createChild('div', 'search-drawer-header'); this._searchPanelElement = this.contentElement.createChild('div', 'search-drawer-header');
this._searchPanelElement.addEventListener('keydown', this._onKeyDown.bind(this), false); this._searchPanelElement.addEventListener('keydown', this._onKeyDown.bind(this), false);
this._searchPanelElement.addEventListener('input', this._onInput.bind(this), false);
this._searchResultsElement = this.contentElement.createChild('div'); this._searchResultsElement = this.contentElement.createChild('div');
this._searchResultsElement.className = 'search-results'; this._searchResultsElement.className = 'search-results';
const searchContainer = createElement('div');
searchContainer.style.flex = 'auto';
searchContainer.style.justifyContent = 'start';
searchContainer.style.maxWidth = '300px';
this._search = UI.HistoryInput.create();
searchContainer.appendChild(this._search);
this._search.placeholder = Common.UIString('Search');
this._search.setAttribute('type', 'text');
this._search.setAttribute('results', '0');
this._search.setAttribute('size', 42);
const searchItem = new UI.ToolbarItem(searchContainer);
const toolbar = new UI.Toolbar('search-toolbar', this._searchPanelElement); const toolbar = new UI.Toolbar('search-toolbar', this._searchPanelElement);
this._matchCaseButton = Search.SearchView._appendToolbarToggle(toolbar, 'Aa', Common.UIString('Match Case')); this._matchCaseButton = Search.SearchView._appendToolbarToggle(toolbar, 'Aa', Common.UIString('Match Case'));
this._regexButton = this._regexButton =
Search.SearchView._appendToolbarToggle(toolbar, '.*', Common.UIString('Use Regular Expression')); Search.SearchView._appendToolbarToggle(toolbar, '.*', Common.UIString('Use Regular Expression'));
toolbar.appendSpacer(); toolbar.appendToolbarItem(searchItem);
const refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'largeicon-refresh'); const refreshButton = new UI.ToolbarButton(Common.UIString('Refresh'), 'largeicon-refresh');
const clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeicon-clear'); const clearButton = new UI.ToolbarButton(Common.UIString('Clear'), 'largeicon-clear');
toolbar.appendToolbarItem(refreshButton); toolbar.appendToolbarItem(refreshButton);
...@@ -55,23 +66,6 @@ Search.SearchView = class extends UI.VBox { ...@@ -55,23 +66,6 @@ Search.SearchView = class extends UI.VBox {
this._onSearchInputClear(); this._onSearchInputClear();
}); });
const searchContainer = this._searchPanelElement.createChild('div', 'search-container');
this._search = UI.HistoryInput.create();
searchContainer.appendChild(this._search);
this._search.placeholder = Common.UIString('Search');
this._search.setAttribute('type', 'text');
this._search.classList.add('search-config-search');
this._search.setAttribute('results', '0');
this._search.setAttribute('size', 42);
this._searchInputClearElement = UI.Icon.create('mediumicon-gray-cross-hover', 'search-cancel-button');
this._searchInputClearElement.classList.add('hidden');
this._searchInputClearElement.addEventListener('click', this._onSearchInputClear.bind(this), false);
const cancelButtonContainer = searchContainer.createChild('div', 'search-cancel-button-container');
cancelButtonContainer.appendChild(this._searchInputClearElement);
const searchStatusBarElement = this.contentElement.createChild('div', 'search-toolbar-summary'); const searchStatusBarElement = this.contentElement.createChild('div', 'search-toolbar-summary');
this._searchMessageElement = searchStatusBarElement.createChild('div', 'search-message'); this._searchMessageElement = searchStatusBarElement.createChild('div', 'search-message');
this._searchProgressPlaceholderElement = searchStatusBarElement.createChild('div', 'flex-centered'); this._searchProgressPlaceholderElement = searchStatusBarElement.createChild('div', 'flex-centered');
...@@ -177,7 +171,6 @@ Search.SearchView = class extends UI.VBox { ...@@ -177,7 +171,6 @@ Search.SearchView = class extends UI.VBox {
_onSearchInputClear() { _onSearchInputClear() {
this._search.value = ''; this._search.value = '';
this.focus(); this.focus();
this._searchInputClearElement.classList.add('hidden');
} }
/** /**
...@@ -357,11 +350,6 @@ Search.SearchView = class extends UI.VBox { ...@@ -357,11 +350,6 @@ Search.SearchView = class extends UI.VBox {
} }
} }
_onInput() {
const hasText = this._search.value && this._search.value.length;
this._searchInputClearElement.classList.toggle('hidden', !hasText);
}
_save() { _save() {
this._advancedSearchConfig.set(this._buildSearchConfig().toPlainObject()); this._advancedSearchConfig.set(this._buildSearchConfig().toPlainObject());
} }
...@@ -371,9 +359,6 @@ Search.SearchView = class extends UI.VBox { ...@@ -371,9 +359,6 @@ Search.SearchView = class extends UI.VBox {
this._search.value = searchConfig.query(); this._search.value = searchConfig.query();
this._matchCaseButton.setToggled(!searchConfig.ignoreCase()); this._matchCaseButton.setToggled(!searchConfig.ignoreCase());
this._regexButton.setToggled(searchConfig.isRegex()); this._regexButton.setToggled(searchConfig.isRegex());
if (this._search.value && this._search.value.length)
this._searchInputClearElement.classList.remove('hidden');
} }
_onAction() { _onAction() {
......
...@@ -10,34 +10,9 @@ ...@@ -10,34 +10,9 @@
overflow: hidden; overflow: hidden;
} }
.search-drawer-header input.search-config-search { .search-toolbar {
border: none; background-color: var(--toolbar-bg-color);
flex-grow: 1; border-bottom: var(--divider-border);
height: 22px;
margin: 2px 2px 2px 2px;
padding-left: 2px;
}
.search-drawer-header input.search-config-search:focus {
box-shadow: var(--focus-ring-active-shadow);
}
.search-config-search::-webkit-search-cancel-button {
-webkit-appearance: none;
}
.search-drawer-header .search-cancel-button-container {
position: relative;
}
.search-drawer-header .search-cancel-button {
position: absolute;
right: 6px;
top: 6px;
}
:host-context(.platform-mac) .search-drawer-header input.search-config-search {
top: 1px;
} }
.search-toolbar-summary { .search-toolbar-summary {
...@@ -66,14 +41,3 @@ ...@@ -66,14 +41,3 @@
.search-view .search-results > div { .search-view .search-results > div {
flex: auto; flex: auto;
} }
.search-container {
display: flex;
flex-grow: 1;
margin: 4px;
}
.search-container:focus-within {
background-color: transparent;
border-color: transparent;
}
...@@ -10,14 +10,18 @@ Sources.SearchSourcesView = class extends Search.SearchView { ...@@ -10,14 +10,18 @@ Sources.SearchSourcesView = class extends Search.SearchView {
/** /**
* @param {string} query * @param {string} query
* @param {boolean=} searchImmediately * @param {boolean=} searchImmediately
* @return {!Promise<!Search.SearchView>} * @return {!Promise}
*/ */
static async openSearch(query, searchImmediately) { static async openSearch(query, searchImmediately) {
await UI.viewManager.showView('sources.search-sources-tab'); const view = UI.viewManager.view('sources.search-sources-tab');
const searchView = // Deliberately use target location name so that it could be changed
/** @type {!Search.SearchView} */ (self.runtime.sharedInstance(Sources.SearchSourcesView)); // based on the setting later.
searchView.toggle(query, !!searchImmediately); const location = await UI.viewManager.resolveLocation('drawer-view');
return searchView; location.appendView(view);
await UI.viewManager.revealView(/** @type {!UI.View} */ (view));
const widget = /** @type {!Search.SearchView} */ (await view.widget());
widget.toggle(query, !!searchImmediately);
return widget;
} }
/** /**
......
...@@ -317,11 +317,11 @@ ...@@ -317,11 +317,11 @@
}, },
{ {
"type": "view", "type": "view",
"location": "navigator-view", "location": "drawer-view",
"id": "sources.search-sources-tab", "id": "sources.search-sources-tab",
"title": "Search", "title": "Search",
"order": 7, "order": 7,
"persistence": "permanent", "persistence": "closeable",
"className": "Sources.SearchSourcesView" "className": "Sources.SearchSourcesView"
}, },
{ {
......
...@@ -5,10 +5,6 @@ ...@@ -5,10 +5,6 @@
* @unrestricted * @unrestricted
*/ */
UI.HistoryInput = class extends HTMLInputElement { UI.HistoryInput = class extends HTMLInputElement {
constructor() {
super();
}
/** /**
* @return {!UI.HistoryInput} * @return {!UI.HistoryInput}
*/ */
......
...@@ -364,7 +364,7 @@ UI.ViewManager = class { ...@@ -364,7 +364,7 @@ UI.ViewManager = class {
return location.showView(view, undefined, userGesture, omitFocus); return location.showView(view, undefined, userGesture, omitFocus);
} }
return this._resolveLocation(locationName).then(location => { return this.resolveLocation(locationName).then(location => {
if (!location) if (!location)
throw new Error('Could not resolve location for view: ' + viewId); throw new Error('Could not resolve location for view: ' + viewId);
location._reveal(); location._reveal();
...@@ -376,7 +376,7 @@ UI.ViewManager = class { ...@@ -376,7 +376,7 @@ UI.ViewManager = class {
* @param {string=} location * @param {string=} location
* @return {!Promise<?UI.ViewManager._Location>} * @return {!Promise<?UI.ViewManager._Location>}
*/ */
_resolveLocation(location) { resolveLocation(location) {
if (!location) if (!location)
return /** @type {!Promise<?UI.ViewManager._Location>} */ (Promise.resolve(null)); return /** @type {!Promise<?UI.ViewManager._Location>} */ (Promise.resolve(null));
...@@ -730,10 +730,12 @@ UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { ...@@ -730,10 +730,12 @@ UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location {
appendView(view, insertBefore) { appendView(view, insertBefore) {
if (this._tabbedPane.hasTab(view.viewId())) if (this._tabbedPane.hasTab(view.viewId()))
return; return;
const oldLocation = view[UI.ViewManager._Location.symbol];
if (oldLocation && oldLocation !== this)
oldLocation.removeView(view);
view[UI.ViewManager._Location.symbol] = this; view[UI.ViewManager._Location.symbol] = this;
this._manager._views.set(view.viewId(), view); this._manager._views.set(view.viewId(), view);
this._views.set(view.viewId(), view); this._views.set(view.viewId(), view);
let index = undefined; let index = undefined;
const tabIds = this._tabbedPane.tabIds(); const tabIds = this._tabbedPane.tabIds();
if (this._allowReorder) { if (this._allowReorder) {
...@@ -793,8 +795,8 @@ UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location { ...@@ -793,8 +795,8 @@ UI.ViewManager._TabbedLocation = class extends UI.ViewManager._Location {
delete view[UI.ViewManager._Location.symbol]; delete view[UI.ViewManager._Location.symbol];
this._manager._views.delete(view.viewId()); this._manager._views.delete(view.viewId());
this._views.delete(view.viewId());
this._tabbedPane.closeTab(view.viewId()); this._tabbedPane.closeTab(view.viewId());
this._views.delete(view.viewId());
} }
/** /**
...@@ -858,6 +860,10 @@ UI.ViewManager._StackLocation = class extends UI.ViewManager._Location { ...@@ -858,6 +860,10 @@ UI.ViewManager._StackLocation = class extends UI.ViewManager._Location {
* @param {?UI.View=} insertBefore * @param {?UI.View=} insertBefore
*/ */
appendView(view, insertBefore) { appendView(view, insertBefore) {
const oldLocation = view[UI.ViewManager._Location.symbol];
if (oldLocation && oldLocation !== this)
oldLocation.removeView(view);
let container = this._expandableContainers.get(view.viewId()); let container = this._expandableContainers.get(view.viewId());
if (!container) { if (!container) {
view[UI.ViewManager._Location.symbol] = this; view[UI.ViewManager._Location.symbol] = this;
......
...@@ -327,3 +327,17 @@ select.toolbar-item[data-keyboard-focus="true"]:focus > * { ...@@ -327,3 +327,17 @@ select.toolbar-item[data-keyboard-focus="true"]:focus > * {
width: 28px; width: 28px;
left: -2px; left: -2px;
} }
input[is=history-input] {
border: none;
line-height: 16px;
padding: 1px;
}
input[is=history-input]:hover {
box-shadow: var(--focus-ring-inactive-shadow);
}
input[is=history-input]:focus {
box-shadow: var(--focus-ring-active-shadow);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment