Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (260588 => 260589)
--- trunk/Source/WebInspectorUI/ChangeLog 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/ChangeLog 2020-04-23 19:49:01 UTC (rev 260589)
@@ -1,3 +1,57 @@
+2020-04-23 Devin Rousso <drou...@apple.com>
+
+ Web Inspector: Uncaught Exception: SyntaxError: Invalid regular _expression_: missing )
+ https://bugs.webkit.org/show_bug.cgi?id=210890
+
+ Reviewed by Brian Burg.
+
+ * UserInterface/Base/SearchUtilities.js:
+ (WI.SearchUtilities.prototype._regExpForString):
+ Catch any exceptions from `new RegExp` and return `null` in that case.
+
+ * UserInterface/Views/FilterBar.js:
+ (WI.FilterBar):
+ (WI.FilterBar.prototype.get invalid): Added.
+ (WI.FilterBar.prototype.set invalid): Added.
+ (WI.FilterBar.prototype.clear):
+ * UserInterface/Views/FilterBar.css:
+ (:matches(.filter-bar, .search-bar).invalid > input[type="search"]): Added.
+ * UserInterface/Views/CookieStorageContentView.js:
+ (WI.CookieStorageContentView.prototype._updateFilteredCookies):
+ * UserInterface/Views/IndexedDatabaseObjectStoreContentView.js:
+ (WI.IndexedDatabaseObjectStoreContentView.prototype.dataGridMatchNodeAgainstCustomFilters):
+ * UserInterface/Views/NavigationSidebarPanel.js:
+ (WI.NavigationSidebarPanel.prototype.updateFilter):
+ * UserInterface/Views/NetworkTableContentView.js:
+ (WI.NetworkTableContentView.prototype._urlFilterDidChange):
+ * UserInterface/Views/SearchSidebarPanel.js:
+ (WI.SearchSidebarPanel):
+ (WI.SearchSidebarPanel.prototype.performSearch):
+ (WI.SearchSidebarPanel.prototype.performSearch.forEachMatch):
+ * UserInterface/Views/SearchSidebarPanel.css:
+ (.sidebar > .panel.navigation.search > .search-bar > input[type="search"]): Added.
+ Mark the `WI.FilterBar` as invalid if the `filterRegExpForString` is invalid.
+
+ * UserInterface/Views/DOMTreeElement.js:
+ (WI.DOMTreeElement.prototype._highlightSearchResults):
+ * UserInterface/Views/LogContentView.js:
+ (WI.LogContentView.prototype.performSearch):
+ * UserInterface/Views/ResourceHeadersContentView.js:
+ (WI.ResourceHeadersContentView.prototype._perfomSearchOnKeyValuePairs):
+ * UserInterface/Views/ResourceSecurityContentView.js:
+ (WI.ResourceSecurityContentView.prototype._perfomSearchOnKeyValuePairs):
+ * UserInterface/Views/SourceCodeTextEditor.js:
+ (WI.SourceCodeTextEditor.prototype.customPerformSearch):
+ (WI.SourceCodeTextEditor.prototype.customPerformSearch.searchResultCallback):
+ * UserInterface/Views/TextEditor.js:
+ (WI.TextEditor.prototype.performSearch):
+ Ensure that the `WI.FindBanner` shows 0 results if the `searchRegExpForString` is invalid.
+
+ * UserInterface/Main.html:
+ * UserInterface/Views/SearchBar.js: Removed.
+ * UserInterface/Views/SearchBar.css: Removed.
+ Removed unused `WI.SearchBar`.
+
2020-04-22 Devin Rousso <drou...@apple.com>
Web Inspector: Storage: unable to filter cookies
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/SearchUtilities.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -99,8 +99,13 @@
console.assert((typeof query === "string" && query) || query instanceof RegExp);
- if (!checkSetting(settings.regularExpression))
- query = simpleGlobStringToRegExp(String(query));
+ if (!checkSetting(settings.regularExpression)) {
+ try {
+ query = simpleGlobStringToRegExp(String(query));
+ } catch {
+ return null;
+ }
+ }
console.assert((typeof query === "string" && query) || query instanceof RegExp);
@@ -110,6 +115,10 @@
if (!checkSetting(settings.caseSensitive))
flags += "i";
- return new RegExp(query, flags);
+ try {
+ return new RegExp(query, flags);
+ } catch {
+ return null;
+ }
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2020-04-23 19:49:01 UTC (rev 260589)
@@ -192,7 +192,6 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
- <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -798,7 +797,6 @@
<script src=""
<script src=""
<script src=""
- <script src=""
<script src=""
<script src=""
<script src=""
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/CookieStorageContentView.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -458,19 +458,29 @@
_updateFilteredCookies()
{
- let filterText = this._filterBarNavigationItem.filterBar.filters.text;
- if (filterText) {
- let regex = WI.SearchUtilities.filterRegExpForString(filterText, WI.SearchUtilities.defaultSettings);
- this._filteredCookies = this._cookies.filter((cookie) => {
- for (let column of this._table.columns) {
- let text = this._formatCookiePropertyForColumn(cookie, column);
- if (text && regex.test(text))
- return true;
- }
- return false;
- });
- } else
- this._filteredCookies = this._cookies;
+ this._filteredCookies = this._cookies;
+
+ let filterBar = this._filterBarNavigationItem.filterBar;
+ filterBar.invalid = false;
+
+ let filterText = filterBar.filters.text;
+ if (!filterText)
+ return;
+
+ let regex = WI.SearchUtilities.filterRegExpForString(filterText, WI.SearchUtilities.defaultSettings);
+ if (!regex) {
+ filterBar.invalid = true;
+ return;
+ }
+
+ this._filteredCookies = this._filteredCookies.filter((cookie) => {
+ for (let column of this._table.columns) {
+ let text = this._formatCookiePropertyForColumn(cookie, column);
+ if (text && regex.test(text))
+ return true;
+ }
+ return false;
+ });
}
_updateEmptyFilterResultsMessage()
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -1809,9 +1809,14 @@
return;
}
- var text = this.title.textContent;
let searchRegex = WI.SearchUtilities.searchRegExpForString(this._searchQuery, WI.SearchUtilities.defaultSettings);
+ if (!searchRegex) {
+ this.hideSearchHighlights();
+ this.dispatchEventToListeners(WI.TextEditor.Event.NumberOfSearchResultsDidChange);
+ return;
+ }
+ var text = this.title.textContent;
var match = searchRegex.exec(text);
var matchRanges = [];
while (match) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.css (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.css 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.css 2020-04-23 19:49:01 UTC (rev 260589)
@@ -112,3 +112,7 @@
:matches(.filter-bar, .search-bar) > input[type="search"] + .navigation-bar > .item.scope-bar:last-child {
-webkit-margin-end: 4px;
}
+
+:matches(.filter-bar, .search-bar).invalid > input[type="search"] {
+ border-color: var(--error-text-color);
+}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/FilterBar.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -47,6 +47,8 @@
this._element.appendChild(this._filtersNavigationBar.element);
this._lastFilterValue = this.filters;
+
+ this._invalid = false;
}
// Public
@@ -81,6 +83,17 @@
this._inputField.incremental = incremental;
}
+ get invalid()
+ {
+ return this._invalid;
+ }
+
+ set invalid(invalid)
+ {
+ this._invalid = !!invalid;
+ this._element.classList.toggle("invalid", this._invalid);
+ }
+
get filters()
{
return {text: this._inputField.value, functions: [...this._filterFunctionsMap.values()]};
@@ -118,6 +131,8 @@
}
this._inputField.value = null; // Get the placeholder to show again.
+
+ this.invalid = false;
}
addFilterNavigationItem(navigationItem)
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseObjectStoreContentView.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -136,11 +136,18 @@
dataGridMatchNodeAgainstCustomFilters(node)
{
- let filterText = this._filterBarNavigationItem.filterBar.filters.text;
+ let filterBar = this._filterBarNavigationItem.filterBar;
+ filterBar.invalid = false;
+
+ let filterText = filterBar.filters.text;
if (!filterText)
return true;
let regex = WI.SearchUtilities.filterRegExpForString(filterText, WI.SearchUtilities.defaultSettings);
+ if (!regex) {
+ filterBar.invalid = true;
+ return true;
+ }
// Iterate over each cell.
for (let child of node.element.children) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -1097,9 +1097,16 @@
return;
}
+ let searchRegex = WI.SearchUtilities.searchRegExpForString(this._currentSearchQuery, WI.SearchUtilities.defaultSettings);
+ if (!searchRegex) {
+ this._findBanner.numberOfResults = 0;
+ this.element.classList.remove(WI.LogContentView.SearchInProgressStyleClassName);
+ this.dispatchEventToListeners(WI.ContentView.Event.NumberOfSearchResultsDidChange);
+ return;
+ }
+
this.element.classList.add(WI.LogContentView.SearchInProgressStyleClassName);
- let searchRegex = WI.SearchUtilities.searchRegExpForString(this._currentSearchQuery, WI.SearchUtilities.defaultSettings);
this._unfilteredMessageElements().forEach(function(message) {
let matchRanges = [];
let text = message.textContent;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -321,6 +321,8 @@
this._filtersSetting.value = filters;
this._filterFunctions = filters.functions;
+ this._filterBar.invalid = filters.text && !this._textFilterRegex;
+
// Don't populate if we don't have any active filters.
// We only need to populate when a filter needs to reveal.
let dontPopulate = !this._filterBar.hasActiveFilters() && !this.shouldFilterPopulate();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -2278,7 +2278,8 @@
_urlFilterDidChange(event)
{
- let searchQuery = this._urlFilterNavigationItem.filterBar.filters.text;
+ let filterBar = this._urlFilterNavigationItem.filterBar;
+ let searchQuery = filterBar.filters.text;
if (searchQuery === this._urlFilterSearchText)
return;
@@ -2285,8 +2286,11 @@
// Even if the selected resource would still be visible, lets close the detail view if a filter changes.
this._hideDetailView();
+ this._urlFilterSearchRegex = searchQuery ? WI.SearchUtilities.filterRegExpForString(searchQuery, WI.SearchUtilities.defaultSettings) : null;
+ filterBar.invalid = searchQuery && !this._urlFilterSearchRegex
+
// Search cleared.
- if (!searchQuery) {
+ if (!this._urlFilterSearchRegex) {
this._urlFilterSearchText = null;
this._urlFilterSearchRegex = null;
this._urlFilterIsActive = false;
@@ -2299,7 +2303,6 @@
this._urlFilterIsActive = true;
this._urlFilterSearchText = searchQuery;
- this._urlFilterSearchRegex = WI.SearchUtilities.filterRegExpForString(searchQuery, WI.SearchUtilities.defaultSettings);
this._updateActiveFilterResources();
this._updateFilteredEntries();
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -478,6 +478,11 @@
_perfomSearchOnKeyValuePairs()
{
let searchRegex = WI.SearchUtilities.searchRegExpForString(this._searchQuery, WI.SearchUtilities.defaultSettings);
+ if (!searchRegex) {
+ this.searchCleared();
+ this.dispatchEventToListeners(WI.TextEditor.Event.NumberOfSearchResultsDidChange);
+ return;
+ }
let elements = this.element.querySelectorAll(".key, .value");
for (let element of elements) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSecurityContentView.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -287,6 +287,11 @@
_perfomSearchOnKeyValuePairs()
{
let searchRegex = WI.SearchUtilities.searchRegExpForString(this._searchQuery, WI.SearchUtilities.defaultSettings);
+ if (!searchRegex) {
+ this.searchCleared();
+ this.dispatchEventToListeners(WI.TextEditor.Event.NumberOfSearchResultsDidChange);
+ return;
+ }
let elements = this.element.querySelectorAll(".key, .value");
for (let element of elements) {
Deleted: trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.css 2020-04-23 19:49:01 UTC (rev 260589)
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2019 Apple 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 APPLE 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 APPLE 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.
- */
-
-.search-bar > input[type="search"] {
- margin: 1px 6px;
-}
-
-/* Many styles shared with `WI.FilterBar` */
Deleted: trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2013, 2015 Apple 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 APPLE 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 APPLE 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.
- */
-
-WI.SearchBar = class SearchBar extends WI.NavigationItem
-{
- constructor(identifier, placeholder, incremental)
- {
- super(identifier);
-
- this._element.classList.add("search-bar");
-
- this._searchInput = this._element.appendChild(document.createElement("input"));
- this._searchInput.type = "search";
- this._searchInput.spellcheck = false;
- this._searchInput.incremental = incremental;
- this._searchInput.setAttribute("results", 5);
- this._searchInput.setAttribute("autosave", identifier + "-autosave");
- this._searchInput.setAttribute("placeholder", placeholder);
- this._searchInput.addEventListener("search", this._handleSearchEvent.bind(this));
- }
-
- // Public
-
- get text()
- {
- return this._searchInput.value;
- }
-
- set text(newText)
- {
- this._searchInput.value = newText;
- }
-
- focus()
- {
- // FIXME: Workaround for: <https://webkit.org/b/149504> Caret missing from <input> after clearing text and calling select()
- if (!this._searchInput.value.length)
- this._searchInput.focus();
- else
- this._searchInput.select();
- }
-
- // Private
-
- _handleSearchEvent(event)
- {
- this.dispatchEventToListeners(WI.SearchBar.Event.TextChanged);
- }
-};
-
-WI.SearchBar.Event = {
- TextChanged: "searchbar-text-did-change"
-};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css 2020-04-23 19:49:01 UTC (rev 260589)
@@ -41,6 +41,8 @@
.sidebar > .panel.navigation.search > .search-bar > input[type="search"] {
width: 100%;
+ margin: 1px 6px;
+ /* Many styles shared with `WI.FilterBar` */
}
.sidebar > .panel.navigation.search > .search-bar > .search-settings {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -35,11 +35,10 @@
},
});
- var searchElement = document.createElement("div");
- searchElement.classList.add("search-bar");
- this.element.appendChild(searchElement);
+ this._inputContainer = this.element.appendChild(document.createElement("div"));
+ this._inputContainer.classList.add("search-bar");
- this._inputElement = document.createElement("input");
+ this._inputElement = this._inputContainer.appendChild(document.createElement("input"));
this._inputElement.type = "search";
this._inputElement.spellcheck = false;
this._inputElement.addEventListener("search", this._searchFieldChanged.bind(this));
@@ -47,9 +46,8 @@
this._inputElement.setAttribute("results", 5);
this._inputElement.setAttribute("autosave", "inspector-search-autosave");
this._inputElement.setAttribute("placeholder", WI.UIString("Search Resource Content"));
- searchElement.appendChild(this._inputElement);
- searchElement.appendChild(WI.SearchUtilities.createSettingsButton(this._searchInputSettings));
+ this._inputContainer.appendChild(WI.SearchUtilities.createSettingsButton(this._searchInputSettings));
this._searchQuerySetting = new WI.Setting("search-sidebar-query", "");
this._inputElement.value = this._searchQuerySetting.value;
@@ -100,24 +98,36 @@
performSearch(searchQuery)
{
- // Before performing a new search, clear the old search.
- this.contentTreeOutline.removeChildren();
- this.contentBrowser.contentViewContainer.closeAllContentViews();
-
this._inputElement.value = searchQuery;
this._searchQuerySetting.value = searchQuery;
- this.hideEmptyContentPlaceholder();
-
this.element.classList.remove("changed");
if (this._changedBanner)
this._changedBanner.remove();
if (!searchQuery.length) {
+ this._inputContainer.classList.remove("invalid");
+ this.hideEmptyContentPlaceholder();
this.showDefaultContentView();
return;
}
+ let isCaseSensitive = !!this._searchInputSettings.caseSensitive.value;
+ let isRegex = !!this._searchInputSettings.regularExpression.value;
+ let searchRegex = WI.SearchUtilities.searchRegExpForString(searchQuery, {
+ caseSensitive: isCaseSensitive,
+ regularExpression: isRegex,
+ });
+ this._inputContainer.classList.toggle("invalid", !searchRegex);
+ if (!searchRegex)
+ return;
+
+ this.hideEmptyContentPlaceholder();
+
+ // Before performing a new search, clear the old search.
+ this.contentTreeOutline.removeChildren();
+ this.contentBrowser.contentViewContainer.closeAllContentViews();
+
let createSearchingPlaceholder = () => {
let searchingPlaceholder = WI.createMessageTextView("");
String.format(WI.UIString("Searching %s"), [(new WI.IndeterminateProgressSpinner).element], String.standardFormatters, searchingPlaceholder, (a, b) => {
@@ -159,9 +169,6 @@
}
};
- let isCaseSensitive = !!this._searchInputSettings.caseSensitive.value;
- let isRegex = !!this._searchInputSettings.regularExpression.value;
-
function createTreeElementForMatchObject(matchObject, parentTreeElement)
{
let matchTreeElement = new WI.SearchResultTreeElement(matchObject);
@@ -173,13 +180,9 @@
matchTreeElement.revealAndSelect(false, true);
}
- function forEachMatch(searchQuery, lineContent, callback)
+ function forEachMatch(lineContent, callback)
{
var lineMatch;
- let searchRegex = WI.SearchUtilities.searchRegExpForString(searchQuery, {
- caseSensitive: isCaseSensitive,
- regularExpression: isRegex,
- });
while ((searchRegex.lastIndex < lineContent.length) && (lineMatch = searchRegex.exec(lineContent)))
callback(lineMatch, searchRegex.lastIndex);
}
@@ -200,7 +203,7 @@
for (var i = 0; i < result.length; ++i) {
var match = result[i];
- forEachMatch(searchQuery, match.lineContent, (lineMatch, lastIndex) => {
+ forEachMatch(match.lineContent, (lineMatch, lastIndex) => {
var matchObject = new WI.SourceCodeSearchMatchObject(resource, match.lineContent, searchQuery, new WI.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, lastIndex));
createTreeElementForMatchObject.call(this, matchObject, resourceTreeElement);
});
@@ -243,7 +246,7 @@
var scriptTreeElement = this._searchTreeElementForScript(script);
for (let match of result) {
- forEachMatch(searchQuery, match.lineContent, (lineMatch, lastIndex) => {
+ forEachMatch(match.lineContent, (lineMatch, lastIndex) => {
var matchObject = new WI.SourceCodeSearchMatchObject(script, match.lineContent, searchQuery, new WI.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, lastIndex));
createTreeElementForMatchObject.call(this, matchObject, scriptTreeElement);
});
@@ -293,7 +296,7 @@
// Textual matches.
var didFindTextualMatch = false;
- forEachMatch(searchQuery, domNodeTitle, (lineMatch, lastIndex) => {
+ forEachMatch(domNodeTitle, (lineMatch, lastIndex) => {
var matchObject = new WI.DOMSearchMatchObject(resource, domNode, domNodeTitle, searchQuery, new WI.TextRange(0, lineMatch.index, 0, lastIndex));
createTreeElementForMatchObject.call(this, matchObject, resourceTreeElement);
didFindTextualMatch = true;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -208,6 +208,13 @@
customPerformSearch(query)
{
+ let queryRegex = WI.SearchUtilities.searchRegExpForString(query, WI.SearchUtilities.defaultSettings);
+ if (!queryRegex) {
+ this.searchCleared();
+ this.dispatchEventToListeners(WI.TextEditor.Event.NumberOfSearchResultsDidChange);
+ return true;
+ }
+
function searchResultCallback(error, matches)
{
// Bail if the query changed since we started.
@@ -220,7 +227,6 @@
return;
}
- let queryRegex = WI.SearchUtilities.searchRegExpForString(query, WI.SearchUtilities.defaultSettings);
var searchResults = [];
for (var i = 0; i < matches.length; ++i) {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js (260588 => 260589)
--- trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2020-04-23 19:44:03 UTC (rev 260588)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TextEditor.js 2020-04-23 19:49:01 UTC (rev 260589)
@@ -313,8 +313,14 @@
return;
}
+ let queryRegex = WI.SearchUtilities.searchRegExpForString(query, WI.SearchUtilities.defaultSettings);
+ if (!queryRegex) {
+ this.searchCleared();
+ this.dispatchEventToListeners(WI.TextEditor.Event.NumberOfSearchResultsDidChange);
+ return;
+ }
+
// Go down the slow patch for all other text content.
- let queryRegex = WI.SearchUtilities.searchRegExpForString(query, WI.SearchUtilities.defaultSettings);
var searchCursor = this._codeMirror.getSearchCursor(queryRegex, {line: 0, ch: 0}, false);
var boundBatchSearch = batchSearch.bind(this);
var numberOfSearchResultsDidChangeTimeout = null;