| Index: Source/devtools/front_end/AdvancedSearchView.js
|
| diff --git a/Source/devtools/front_end/AdvancedSearchController.js b/Source/devtools/front_end/AdvancedSearchView.js
|
| similarity index 74%
|
| rename from Source/devtools/front_end/AdvancedSearchController.js
|
| rename to Source/devtools/front_end/AdvancedSearchView.js
|
| index 357447180ee90fc50b6bd872d69859e9384bbb49..9d39fb73a386742827bd8d3634330e106fe191f5 100644
|
| --- a/Source/devtools/front_end/AdvancedSearchController.js
|
| +++ b/Source/devtools/front_end/AdvancedSearchView.js
|
| @@ -1,56 +1,77 @@
|
| -/*
|
| - * Copyright (C) 2011 Google Inc. All rights reserved.
|
| - *
|
| - * Redistribution and use in source and binary forms, with or without
|
| - * modification, are permitted provided that the following conditions are
|
| - * met:
|
| - *
|
| - * 1. Redistributions of source code must retain the above copyright
|
| - * notice, this list of conditions and the following disclaimer.
|
| - *
|
| - * 2. Redistributions in binary form must reproduce the above
|
| - * copyright notice, this list of conditions and the following disclaimer
|
| - * in the documentation and/or other materials provided with the
|
| - * distribution.
|
| - *
|
| - * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
|
| - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
|
| - * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| - */
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
|
|
| /**
|
| * @constructor
|
| + * @extends {WebInspector.VBox}
|
| */
|
| -WebInspector.AdvancedSearchController = function()
|
| +WebInspector.AdvancedSearchView = function()
|
| {
|
| + WebInspector.VBox.call(this);
|
| +
|
| this._searchId = 0;
|
|
|
| + this.element.classList.add("search-view");
|
| +
|
| + this._searchPanelElement = this.element.createChild("div", "search-drawer-header");
|
| + this._searchPanelElement.addEventListener("keydown", this._onKeyDown.bind(this), false);
|
| +
|
| + this._searchResultsElement = this.element.createChild("div");
|
| + this._searchResultsElement.className = "search-results";
|
| +
|
| + this._search = this._searchPanelElement.createChild("input");
|
| + this._search.placeholder = WebInspector.UIString("Search sources");
|
| + this._search.setAttribute("type", "text");
|
| + this._search.classList.add("search-config-search");
|
| + this._search.setAttribute("results", "0");
|
| + this._search.setAttribute("size", 30);
|
| +
|
| + this._ignoreCaseLabel = this._searchPanelElement.createChild("label");
|
| + this._ignoreCaseLabel.classList.add("search-config-label");
|
| + this._ignoreCaseCheckbox = this._ignoreCaseLabel.createChild("input");
|
| + this._ignoreCaseCheckbox.setAttribute("type", "checkbox");
|
| + this._ignoreCaseCheckbox.classList.add("search-config-checkbox");
|
| + this._ignoreCaseLabel.appendChild(document.createTextNode(WebInspector.UIString("Ignore case")));
|
| +
|
| + this._regexLabel = this._searchPanelElement.createChild("label");
|
| + this._regexLabel.classList.add("search-config-label");
|
| + this._regexCheckbox = this._regexLabel.createChild("input");
|
| + this._regexCheckbox.setAttribute("type", "checkbox");
|
| + this._regexCheckbox.classList.add("search-config-checkbox");
|
| + this._regexLabel.appendChild(document.createTextNode(WebInspector.UIString("Regular expression")));
|
| +
|
| + this._searchStatusBarElement = this.element.createChild("div", "search-status-bar-summary");
|
| + this._searchMessageElement = this._searchStatusBarElement.createChild("span");
|
| + this._searchResultsMessageElement = document.createElement("span");
|
| +
|
| WebInspector.settings.advancedSearchConfig = WebInspector.settings.createSetting("advancedSearchConfig", new WebInspector.SearchConfig("", true, false).toPlainObject());
|
| + this._load();
|
| }
|
|
|
| -WebInspector.AdvancedSearchController.prototype = {
|
| - show: function()
|
| +WebInspector.AdvancedSearchView.prototype = {
|
| + /**
|
| + * @return {!WebInspector.SearchConfig}
|
| + */
|
| + _buildSearchConfig: function()
|
| + {
|
| + return new WebInspector.SearchConfig(this._search.value, this._ignoreCaseCheckbox.checked, this._regexCheckbox.checked);
|
| + },
|
| +
|
| + toggle: function()
|
| {
|
| var selection = window.getSelection();
|
| var queryCandidate;
|
| if (selection.rangeCount)
|
| queryCandidate = selection.toString().replace(/\r?\n.*/, "");
|
|
|
| - if (!this._searchView || !this._searchView.isShowing())
|
| + if (!this.isShowing())
|
| WebInspector.inspectorView.showViewInDrawer("search");
|
| if (queryCandidate)
|
| - this._searchView._search.value = queryCandidate;
|
| - this._searchView.focus();
|
| + this._search.value = queryCandidate;
|
| + this.focus();
|
|
|
| - this.startIndexing();
|
| + this._startIndexing();
|
| },
|
|
|
| /**
|
| @@ -59,7 +80,7 @@ WebInspector.AdvancedSearchController.prototype = {
|
| _onIndexingFinished: function(finished)
|
| {
|
| delete this._isIndexing;
|
| - this._searchView.indexingFinished(finished);
|
| + this._indexingFinished(finished);
|
| if (!finished)
|
| delete this._pendingSearchConfig;
|
| if (!this._pendingSearchConfig)
|
| @@ -69,7 +90,7 @@ WebInspector.AdvancedSearchController.prototype = {
|
| this._innerStartSearch(searchConfig);
|
| },
|
|
|
| - startIndexing: function()
|
| + _startIndexing: function()
|
| {
|
| this._isIndexing = true;
|
| // FIXME: this._currentSearchScope should be initialized based on searchConfig
|
| @@ -77,7 +98,7 @@ WebInspector.AdvancedSearchController.prototype = {
|
| if (this._progressIndicator)
|
| this._progressIndicator.done();
|
| this._progressIndicator = new WebInspector.ProgressIndicator();
|
| - this._searchView.indexingStarted(this._progressIndicator);
|
| + this._indexingStarted(this._progressIndicator);
|
| this._currentSearchScope.performIndexing(this._progressIndicator, this._onIndexingFinished.bind(this));
|
| },
|
|
|
| @@ -89,12 +110,13 @@ WebInspector.AdvancedSearchController.prototype = {
|
| {
|
| if (searchId !== this._searchId)
|
| return;
|
| - this._searchView.addSearchResult(searchResult);
|
| + this._addSearchResult(searchResult);
|
| if (!searchResult.searchMatches.length)
|
| return;
|
| if (!this._searchResultsPane)
|
| this._searchResultsPane = this._currentSearchScope.createSearchResultsPane(this._searchConfig);
|
| - this._searchView.resultsPane = this._searchResultsPane;
|
| + this._resetResults();
|
| + this._searchResultsElement.appendChild(this._searchResultsPane.element);
|
| this._searchResultsPane.addSearchResult(searchResult);
|
| },
|
|
|
| @@ -107,20 +129,20 @@ WebInspector.AdvancedSearchController.prototype = {
|
| if (searchId !== this._searchId)
|
| return;
|
| if (!this._searchResultsPane)
|
| - this._searchView.nothingFound();
|
| - this._searchView.searchFinished(finished);
|
| + this._nothingFound();
|
| + this._searchFinished(finished);
|
| delete this._searchConfig;
|
| },
|
|
|
| /**
|
| * @param {!WebInspector.SearchConfig} searchConfig
|
| */
|
| - startSearch: function(searchConfig)
|
| + _startSearch: function(searchConfig)
|
| {
|
| - this.resetSearch();
|
| + this._resetSearch();
|
| ++this._searchId;
|
| if (!this._isIndexing)
|
| - this.startIndexing();
|
| + this._startIndexing();
|
| this._pendingSearchConfig = searchConfig;
|
| },
|
|
|
| @@ -136,21 +158,21 @@ WebInspector.AdvancedSearchController.prototype = {
|
| if (this._progressIndicator)
|
| this._progressIndicator.done();
|
| this._progressIndicator = new WebInspector.ProgressIndicator();
|
| - this._searchView.searchStarted(this._progressIndicator);
|
| + this._searchStarted(this._progressIndicator);
|
| this._currentSearchScope.performSearch(searchConfig, this._progressIndicator, this._onSearchResult.bind(this, this._searchId), this._onSearchFinished.bind(this, this._searchId));
|
| },
|
|
|
| - resetSearch: function()
|
| + _resetSearch: function()
|
| {
|
| - this.stopSearch();
|
| + this._stopSearch();
|
|
|
| if (this._searchResultsPane) {
|
| - this._searchView.resetResults();
|
| + this._resetResults();
|
| delete this._searchResultsPane;
|
| }
|
| },
|
|
|
| - stopSearch: function()
|
| + _stopSearch: function()
|
| {
|
| if (this._progressIndicator)
|
| this._progressIndicator.cancel();
|
| @@ -166,80 +188,14 @@ WebInspector.AdvancedSearchController.prototype = {
|
| {
|
| // FIXME: implement multiple search scopes.
|
| return /** @type {!Array.<!WebInspector.SearchScope>} */ (WebInspector.moduleManager.instances(WebInspector.SearchScope));
|
| - }
|
| -}
|
| -
|
| -/**
|
| - * @constructor
|
| - * @extends {WebInspector.VBox}
|
| - */
|
| -WebInspector.SearchView = function()
|
| -{
|
| - WebInspector.VBox.call(this);
|
| -
|
| - this._controller = WebInspector.advancedSearchController;
|
| - WebInspector.advancedSearchController._searchView = this;
|
| -
|
| - this.element.classList.add("search-view");
|
| -
|
| - this._searchPanelElement = this.element.createChild("div", "search-drawer-header");
|
| - this._searchPanelElement.addEventListener("keydown", this._onKeyDown.bind(this), false);
|
| -
|
| - this._searchResultsElement = this.element.createChild("div");
|
| - this._searchResultsElement.className = "search-results";
|
| -
|
| - this._search = this._searchPanelElement.createChild("input");
|
| - this._search.placeholder = WebInspector.UIString("Search sources");
|
| - this._search.setAttribute("type", "text");
|
| - this._search.classList.add("search-config-search");
|
| - this._search.setAttribute("results", "0");
|
| - this._search.setAttribute("size", 30);
|
| -
|
| - this._ignoreCaseLabel = this._searchPanelElement.createChild("label");
|
| - this._ignoreCaseLabel.classList.add("search-config-label");
|
| - this._ignoreCaseCheckbox = this._ignoreCaseLabel.createChild("input");
|
| - this._ignoreCaseCheckbox.setAttribute("type", "checkbox");
|
| - this._ignoreCaseCheckbox.classList.add("search-config-checkbox");
|
| - this._ignoreCaseLabel.appendChild(document.createTextNode(WebInspector.UIString("Ignore case")));
|
| -
|
| - this._regexLabel = this._searchPanelElement.createChild("label");
|
| - this._regexLabel.classList.add("search-config-label");
|
| - this._regexCheckbox = this._regexLabel.createChild("input");
|
| - this._regexCheckbox.setAttribute("type", "checkbox");
|
| - this._regexCheckbox.classList.add("search-config-checkbox");
|
| - this._regexLabel.appendChild(document.createTextNode(WebInspector.UIString("Regular expression")));
|
| -
|
| - this._searchStatusBarElement = this.element.createChild("div", "search-status-bar-summary");
|
| - this._searchMessageElement = this._searchStatusBarElement.createChild("span");
|
| - this._searchResultsMessageElement = document.createElement("span");
|
| -
|
| - this._load();
|
| -}
|
| -
|
| -WebInspector.SearchView.prototype = {
|
| - /**
|
| - * @return {!WebInspector.SearchConfig}
|
| - */
|
| - get searchConfig()
|
| - {
|
| - return new WebInspector.SearchConfig(this._search.value, this._ignoreCaseCheckbox.checked, this._regexCheckbox.checked);
|
| - },
|
| -
|
| - /**
|
| - * @type {!WebInspector.SearchResultsPane}
|
| - */
|
| - set resultsPane(resultsPane)
|
| - {
|
| - this.resetResults();
|
| - this._searchResultsElement.appendChild(resultsPane.element);
|
| },
|
|
|
| /**
|
| * @param {!WebInspector.ProgressIndicator} progressIndicator
|
| */
|
| - searchStarted: function(progressIndicator)
|
| + _searchStarted: function(progressIndicator)
|
| {
|
| - this.resetResults();
|
| + this._resetResults();
|
| this._resetCounters();
|
|
|
| this._searchMessageElement.textContent = WebInspector.UIString("Searching...");
|
| @@ -254,7 +210,7 @@ WebInspector.SearchView.prototype = {
|
| /**
|
| * @param {!WebInspector.ProgressIndicator} progressIndicator
|
| */
|
| - indexingStarted: function(progressIndicator)
|
| + _indexingStarted: function(progressIndicator)
|
| {
|
| this._searchMessageElement.textContent = WebInspector.UIString("Indexing...");
|
| progressIndicator.show(this._searchStatusBarElement);
|
| @@ -263,7 +219,7 @@ WebInspector.SearchView.prototype = {
|
| /**
|
| * @param {boolean} finished
|
| */
|
| - indexingFinished: function(finished)
|
| + _indexingFinished: function(finished)
|
| {
|
| this._searchMessageElement.textContent = finished ? "" : WebInspector.UIString("Indexing interrupted.");
|
| },
|
| @@ -276,7 +232,7 @@ WebInspector.SearchView.prototype = {
|
| this._searchResultsMessageElement.textContent = "";
|
| },
|
|
|
| - resetResults: function()
|
| + _resetResults: function()
|
| {
|
| if (this._searchingView)
|
| this._searchingView.detach();
|
| @@ -292,9 +248,9 @@ WebInspector.SearchView.prototype = {
|
| this._nonEmptySearchResultsCount = 0;
|
| },
|
|
|
| - nothingFound: function()
|
| + _nothingFound: function()
|
| {
|
| - this.resetResults();
|
| + this._resetResults();
|
|
|
| if (!this._notFoundView)
|
| this._notFoundView = new WebInspector.EmptyView(WebInspector.UIString("No matches found."));
|
| @@ -305,7 +261,7 @@ WebInspector.SearchView.prototype = {
|
| /**
|
| * @param {!WebInspector.FileBasedSearchResult} searchResult
|
| */
|
| - addSearchResult: function(searchResult)
|
| + _addSearchResult: function(searchResult)
|
| {
|
| this._searchMatchesCount += searchResult.searchMatches.length;
|
| this._searchResultsCount++;
|
| @@ -317,7 +273,7 @@ WebInspector.SearchView.prototype = {
|
| /**
|
| * @param {boolean} finished
|
| */
|
| - searchFinished: function(finished)
|
| + _searchFinished: function(finished)
|
| {
|
| this._searchMessageElement.textContent = finished ? WebInspector.UIString("Search finished.") : WebInspector.UIString("Search interrupted.");
|
| },
|
| @@ -330,7 +286,7 @@ WebInspector.SearchView.prototype = {
|
|
|
| willHide: function()
|
| {
|
| - this._controller.stopSearch();
|
| + this._stopSearch();
|
| },
|
|
|
| /**
|
| @@ -347,7 +303,7 @@ WebInspector.SearchView.prototype = {
|
|
|
| _save: function()
|
| {
|
| - WebInspector.settings.advancedSearchConfig.set(this.searchConfig.toPlainObject());
|
| + WebInspector.settings.advancedSearchConfig.set(this._buildSearchConfig().toPlainObject());
|
| },
|
|
|
| _load: function()
|
| @@ -360,12 +316,12 @@ WebInspector.SearchView.prototype = {
|
|
|
| _onAction: function()
|
| {
|
| - var searchConfig = this.searchConfig;
|
| + var searchConfig = this._buildSearchConfig();
|
| if (!searchConfig.query() || !searchConfig.query().length)
|
| return;
|
|
|
| this._save();
|
| - this._controller.startSearch(searchConfig);
|
| + this._startSearch(searchConfig);
|
| },
|
|
|
| __proto__: WebInspector.VBox.prototype
|
| @@ -400,11 +356,11 @@ WebInspector.SearchResultsPane.prototype = {
|
| * @constructor
|
| * @implements {WebInspector.ActionDelegate}
|
| */
|
| -WebInspector.AdvancedSearchController.ToggleDrawerViewActionDelegate = function()
|
| +WebInspector.AdvancedSearchView.ToggleDrawerViewActionDelegate = function()
|
| {
|
| }
|
|
|
| -WebInspector.AdvancedSearchController.ToggleDrawerViewActionDelegate.prototype = {
|
| +WebInspector.AdvancedSearchView.ToggleDrawerViewActionDelegate.prototype = {
|
| /**
|
| * @param {!Event} event
|
| * @return {boolean}
|
| @@ -413,14 +369,33 @@ WebInspector.AdvancedSearchController.ToggleDrawerViewActionDelegate.prototype =
|
| {
|
| if (WebInspector.Dialog.currentInstance())
|
| return false;
|
| - var searchView = WebInspector.advancedSearchController._searchView;
|
| - if (!searchView || !searchView.isShowing() || searchView._search !== document.activeElement) {
|
| + var searchView = this._searchView();
|
| + if (!searchView)
|
| + return false;
|
| + if (!searchView.isShowing() || searchView._search !== document.activeElement) {
|
| WebInspector.inspectorView.showPanel("sources");
|
| - WebInspector.advancedSearchController.show();
|
| + searchView.toggle();
|
| } else {
|
| WebInspector.inspectorView.closeDrawer();
|
| }
|
| return true;
|
| + },
|
| +
|
| + /**
|
| + * @return {?WebInspector.AdvancedSearchView}
|
| + */
|
| + _searchView: function()
|
| + {
|
| + if (!this._view) {
|
| + var extensions = WebInspector.moduleManager.extensions("drawer-view");
|
| + for (var i = 0; i < extensions.length; ++i) {
|
| + if (extensions[i].descriptor()["name"] === "search") {
|
| + this._view = extensions[i].instance();
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + return this._view;
|
| }
|
| }
|
|
|
| @@ -466,11 +441,6 @@ WebInspector.SearchScope.prototype = {
|
| createSearchResultsPane: function(searchConfig) { }
|
| }
|
|
|
| -/**
|
| - * @type {!WebInspector.AdvancedSearchController}
|
| - */
|
| -WebInspector.advancedSearchController = new WebInspector.AdvancedSearchController();
|
| -
|
| importScript("SearchConfig.js");
|
| importScript("FileBasedSearchResultsPane.js");
|
| importScript("SourcesSearchScope.js");
|
|
|