Web Inspector: don't immediately attempt to perform a search whenever the find string...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2020 14:49:03 +0000 (14:49 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Apr 2020 14:49:03 +0000 (14:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=211164

Reviewed by Timothy Hatcher.

* UserInterface/Base/Main.js:
(WI.updateFindString):
(WI._populateFind):
* UserInterface/Views/ContentBrowser.js:
(WI.ContentBrowser.prototype.handlePopulateFindShortcut):
(WI.ContentBrowser.prototype.handleFindStringUpdated): Deleted.
Only update the `searchQuery` of the `WI.FindBanner` and `performSearch` when the find
next/previous keyboard shortcut is activated, not when the find string is populated/updated,
unless the update came from the populate find keyboard shortcut.

* UserInterface/Views/LogContentView.js:
(WI.LogContentView.prototype.handlePopulateFindShortcut):
(WI.LogContentView.prototype.handleFindNextShortcut):
(WI.LogContentView.prototype.handleFindPreviousShortcut):
(WI.LogContentView.prototype.highlightPreviousSearchMatch):
(WI.LogContentView.prototype.highlightNextSearchMatch):
(WI.LogContentView.prototype.handleFindStringUpdated): Deleted.
Ensure that the logic for performing a search if the `searchQuery` of the `WI.FindBanner`
doesn't match the current `WI.findString` is also performed when in the split console.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260895 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js
Source/WebInspectorUI/UserInterface/Views/LogContentView.js

index 9d36f2f..b0761f0 100644 (file)
@@ -1,3 +1,30 @@
+2020-04-29  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: don't immediately attempt to perform a search whenever the find string changes
+        https://bugs.webkit.org/show_bug.cgi?id=211164
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Main.js:
+        (WI.updateFindString):
+        (WI._populateFind):
+        * UserInterface/Views/ContentBrowser.js:
+        (WI.ContentBrowser.prototype.handlePopulateFindShortcut):
+        (WI.ContentBrowser.prototype.handleFindStringUpdated): Deleted.
+        Only update the `searchQuery` of the `WI.FindBanner` and `performSearch` when the find
+        next/previous keyboard shortcut is activated, not when the find string is populated/updated,
+        unless the update came from the populate find keyboard shortcut.
+
+        * UserInterface/Views/LogContentView.js:
+        (WI.LogContentView.prototype.handlePopulateFindShortcut):
+        (WI.LogContentView.prototype.handleFindNextShortcut):
+        (WI.LogContentView.prototype.handleFindPreviousShortcut):
+        (WI.LogContentView.prototype.highlightPreviousSearchMatch):
+        (WI.LogContentView.prototype.highlightNextSearchMatch):
+        (WI.LogContentView.prototype.handleFindStringUpdated): Deleted.
+        Ensure that the logic for performing a search if the `searchQuery` of the `WI.FindBanner`
+        doesn't match the current `WI.findString` is also performed when in the split console.
+
 2020-04-28  Nikita Vasilyev  <nvasilyev@apple.com>
 
         Web Inspector: Debug: "Outline focused element" should also outline elements with tabIndex=0
index 0649756..4bc62b3 100644 (file)
@@ -1047,22 +1047,12 @@ WI.updateVisibilityState = function(visible)
 
 WI.updateFindString = function(findString)
 {
-    if (WI.findString === findString)
-        return;
+    if (!findString || WI.findString === findString)
+        return false;
 
     WI.findString = findString;
 
-    let focusedContentView = WI._focusedContentView();
-    if (focusedContentView && focusedContentView.supportsCustomFindBanner) {
-        focusedContentView.handleFindStringUpdated();
-        return;
-    }
-
-    let contentBrowser = WI._focusedOrVisibleContentBrowser();
-    if (contentBrowser) {
-        contentBrowser.handleFindStringUpdated();
-        return;
-    }
+    return true;
 };
 
 WI.handlePossibleLinkClick = function(event, frame, options = {})
@@ -2631,19 +2621,13 @@ WI._populateFind = function(event)
 {
     let focusedContentView = WI._focusedContentView();
     if (focusedContentView && focusedContentView.supportsCustomFindBanner) {
-        let string = focusedContentView.handlePopulateFindShortcut();
-        if (string)
-            WI.findString = string;
-        focusedContentView.handleFindStringUpdated();
+        focusedContentView.handlePopulateFindShortcut();
         return;
     }
 
     let contentBrowser = WI._focusedOrVisibleContentBrowser();
     if (contentBrowser) {
-        let string = contentBrowser.handlePopulateFindShortcut();
-        if (string)
-            WI.findString = string;
-        contentBrowser.handleFindStringUpdated();
+        contentBrowser.handlePopulateFindShortcut();
         return;
     }
 };
index 75d978d..049a471 100644 (file)
@@ -246,18 +246,18 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
 
     // Global ContentBrowser KeyboardShortcut handlers
 
-    handleFindStringUpdated()
+    handlePopulateFindShortcut()
     {
-        this._findBanner.searchQuery = WI.findString;
-
         let currentContentView = this.currentContentView;
-        if (currentContentView?.supportsSearch)
-            currentContentView.performSearch(this._findBanner.searchQuery);
-    }
+        if (!currentContentView?.supportsSearch)
+            return;
 
-    handlePopulateFindShortcut()
-    {
-        return this.currentContentView?.searchQueryWithSelection();
+        if (!WI.updateFindString(currentContentView.searchQueryWithSelection()))
+            return;
+
+        this._findBanner.searchQuery = WI.findString;
+
+        currentContentView.performSearch(this._findBanner.searchQuery);
     }
 
     async handleFindNextShortcut()
index 152b8a1..56809fc 100644 (file)
@@ -296,32 +296,24 @@ WI.LogContentView = class LogContentView extends WI.ContentView
         this._logViewController.requestClearMessages();
     }
 
-    handleFindStringUpdated()
+    handlePopulateFindShortcut()
     {
+        if (!WI.updateFindString(this.searchQueryWithSelection()))
+            return;
+
         this._findBanner.searchQuery = WI.findString;
 
         this.performSearch(this._findBanner.searchQuery);
     }
 
-    handlePopulateFindShortcut()
-    {
-        return this.searchQueryWithSelection();
-    }
-
     handleFindNextShortcut()
     {
-        if (this._findBanner.searchQuery !== WI.findString)
-            this.handleFindStringUpdated();
-
-        this.findBannerRevealNextResult(this._findBanner);
+        this.highlightNextSearchMatch();
     }
 
     handleFindPreviousShortcut()
     {
-        if (this._findBanner.searchQuery !== WI.findString)
-            this.handleFindStringUpdated();
-
-        this.findBannerRevealPreviousResult(this._findBanner);
+        this.highlightPreviousSearchMatch();
     }
 
     findBannerRevealPreviousResult()
@@ -331,7 +323,13 @@ WI.LogContentView = class LogContentView extends WI.ContentView
 
     highlightPreviousSearchMatch()
     {
-        if (!this.hasPerformedSearch || isEmptyObject(this._searchMatches))
+        if (!this.hasPerformedSearch || this._findBanner.searchQuery !== WI.findString) {
+            this._findBanner.searchQuery = WI.findString;
+
+            this.performSearch(this._findBanner.searchQuery);
+        }
+
+        if (isEmptyObject(this._searchMatches))
             return;
 
         var index = this._selectedSearchMatch ? this._searchMatches.indexOf(this._selectedSearchMatch) : this._searchMatches.length;
@@ -345,7 +343,13 @@ WI.LogContentView = class LogContentView extends WI.ContentView
 
     highlightNextSearchMatch()
     {
-        if (!this.hasPerformedSearch || isEmptyObject(this._searchMatches))
+        if (!this.hasPerformedSearch || this._findBanner.searchQuery !== WI.findString) {
+            this._findBanner.searchQuery = WI.findString;
+
+            this.performSearch(this._findBanner.searchQuery);
+        }
+
+        if (isEmptyObject(this._searchMatches))
             return;
 
         var index = this._selectedSearchMatch ? this._searchMatches.indexOf(this._selectedSearchMatch) + 1 : 0;