Title: [260847] trunk/Source
Revision
260847
Author
[email protected]
Date
2020-04-28 14:43:13 -0700 (Tue, 28 Apr 2020)

Log Message

Web Inspector: find dialog does not populate search string from system find pasteboard
https://bugs.webkit.org/show_bug.cgi?id=113588
<rdar://problem/19281466>

Reviewed by Brian Burg.

Source/WebInspectorUI:

* UserInterface/Protocol/InspectorFrontendAPI.js:
(InspectorFrontendAPI.updateFindString): Added.
* UserInterface/Base/Main.js:
(WI.contentLoaded):
(WI.updateFindString): Added.
(WI._populateFind):
(WI._findNext):
(WI._findPrevious):
* UserInterface/Views/ContentBrowser.js:
(WI.ContentBrowser.prototype.handleFindStringUpdated): Added.
(WI.ContentBrowser.prototype.handlePopulateFindShortcut):
(WI.ContentBrowser.prototype.handleFindNextShortcut):
(WI.ContentBrowser.prototype.handleFindPreviousShortcut):
* UserInterface/Views/LogContentView.js:
(WI.LogContentView.prototype.handleFindStringUpdated): Added.
(WI.LogContentView.prototype.handlePopulateFindShortcut):
(WI.LogContentView.prototype.handleFindNextShortcut):
(WI.LogContentView.prototype.handleFindPreviousShortcut):
When the find string gets updated, tell the active view. The `findNextKeyboardShortcut` and
`findPreviousKeyboardShortcut` will also update the related `WI.FindBanner` when invoked if
the current search query does not match the find string.

* UserInterface/Test/Test.js:
(WI.updateFindString): Added.

Source/WebKit:

* UIProcess/Inspector/mac/WKInspectorWKWebView.h:
* UIProcess/Inspector/mac/WKInspectorWKWebView.mm:
(-[WKInspectorWKWebView dealloc]): Added.
(-[WKInspectorWKWebView setInspectorWKWebViewDelegate:]):
(-[WKInspectorWKWebView becomeFirstResponder]): Added.
(-[WKInspectorWKWebView _handleWindowDidBecomeKey:]): Added.
* UIProcess/Inspector/mac/WKInspectorViewController.h:
* UIProcess/Inspector/mac/WKInspectorViewController.mm:
(-[WKInspectorViewController inspectorWKWebViewDidBecomeActive:]): Added.
* UIProcess/Inspector/WebInspectorProxy.h:
* UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
(-[WKWebInspectorProxyObjCAdapter inspectorViewControllerDidBecomeActive:]): Added.
(WebKit::WebInspectorProxy::didBecomeActive): Added.
* UIProcess/Inspector/RemoteWebInspectorProxy.h:
* UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm:
(-[WKRemoteWebInspectorProxyObjCAdapter inspectorWKWebViewDidBecomeActive:]): Added.
(WebKit::RemoteWebInspectorProxy::didBecomeActive): Added.
Add a new delegate call chain that notifies the inspector proxy about when the inspector web
view becomes active, at which point the inspector proxy can get the current find string and
sent it to the inspector page.

* WebProcess/Inspector/WebInspectorUI.messages.in:
* WebProcess/Inspector/WebInspectorUI.h:
* WebProcess/Inspector/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::updateFindString): Added.
* WebProcess/Inspector/RemoteWebInspectorUI.messages.in:
* WebProcess/Inspector/RemoteWebInspectorUI.h:
* WebProcess/Inspector/RemoteWebInspectorUI.cpp:
(WebKit::RemoteWebInspectorUI::updateFindString): Added.
Pass along the new find string to the frontend via `InspectorFrontendAPI.updateFindString`.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (260846 => 260847)


--- trunk/Source/WebInspectorUI/ChangeLog	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebInspectorUI/ChangeLog	2020-04-28 21:43:13 UTC (rev 260847)
@@ -1,3 +1,36 @@
+2020-04-28  Devin Rousso  <[email protected]>
+
+        Web Inspector: find dialog does not populate search string from system find pasteboard
+        https://bugs.webkit.org/show_bug.cgi?id=113588
+        <rdar://problem/19281466>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Protocol/InspectorFrontendAPI.js:
+        (InspectorFrontendAPI.updateFindString): Added.
+        * UserInterface/Base/Main.js:
+        (WI.contentLoaded):
+        (WI.updateFindString): Added.
+        (WI._populateFind):
+        (WI._findNext):
+        (WI._findPrevious):
+        * UserInterface/Views/ContentBrowser.js:
+        (WI.ContentBrowser.prototype.handleFindStringUpdated): Added.
+        (WI.ContentBrowser.prototype.handlePopulateFindShortcut):
+        (WI.ContentBrowser.prototype.handleFindNextShortcut):
+        (WI.ContentBrowser.prototype.handleFindPreviousShortcut):
+        * UserInterface/Views/LogContentView.js:
+        (WI.LogContentView.prototype.handleFindStringUpdated): Added.
+        (WI.LogContentView.prototype.handlePopulateFindShortcut):
+        (WI.LogContentView.prototype.handleFindNextShortcut):
+        (WI.LogContentView.prototype.handleFindPreviousShortcut):
+        When the find string gets updated, tell the active view. The `findNextKeyboardShortcut` and
+        `findPreviousKeyboardShortcut` will also update the related `WI.FindBanner` when invoked if
+        the current search query does not match the find string.
+
+        * UserInterface/Test/Test.js:
+        (WI.updateFindString): Added.
+
 2020-04-28  Christopher Reid  <[email protected]>
 
         [Win] Bundle Inspector Resources in Release builds

Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (260846 => 260847)


--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js	2020-04-28 21:43:13 UTC (rev 260847)
@@ -290,7 +290,7 @@
 
     WI.clearKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "K", WI._clear);
 
-    // FIXME: <https://webkit.org/b/151310> Web Inspector: Command-E should propagate to other search fields (including the system)
+    WI.findString = "";
     WI.populateFindKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "E", WI._populateFind);
     WI.populateFindKeyboardShortcut.implicitlyPreventsDefault = false;
     WI.findNextKeyboardShortcut = new WI.KeyboardShortcut(WI.KeyboardShortcut.Modifier.CommandOrControl, "G", WI._findNext);
@@ -1045,6 +1045,26 @@
     WI.notifications.dispatchEventToListeners(WI.Notification.VisibilityStateDidChange);
 };
 
+WI.updateFindString = function(findString)
+{
+    if (WI.findString === findString)
+        return;
+
+    WI.findString = findString;
+
+    let focusedContentView = WI._focusedContentView();
+    if (focusedContentView && focusedContentView.supportsCustomFindBanner) {
+        focusedContentView.handleFindStringUpdated();
+        return;
+    }
+
+    let contentBrowser = WI._focusedOrVisibleContentBrowser();
+    if (contentBrowser) {
+        contentBrowser.handleFindStringUpdated();
+        return;
+    }
+};
+
 WI.handlePossibleLinkClick = function(event, frame, options = {})
 {
     let anchorElement = event.target.closest("a");
@@ -2610,55 +2630,52 @@
 WI._populateFind = function(event)
 {
     let focusedContentView = WI._focusedContentView();
-    if (!focusedContentView)
+    if (focusedContentView && focusedContentView.supportsCustomFindBanner) {
+        let string = focusedContentView.handlePopulateFindShortcut();
+        if (string)
+            WI.findString = string;
+        focusedContentView.handleFindStringUpdated();
         return;
-
-    if (focusedContentView.supportsCustomFindBanner) {
-        focusedContentView.handlePopulateFindShortcut();
-        return;
     }
 
     let contentBrowser = WI._focusedOrVisibleContentBrowser();
-    if (!contentBrowser)
+    if (contentBrowser) {
+        let string = contentBrowser.handlePopulateFindShortcut();
+        if (string)
+            WI.findString = string;
+        contentBrowser.handleFindStringUpdated();
         return;
-
-    contentBrowser.handlePopulateFindShortcut();
+    }
 };
 
 WI._findNext = function(event)
 {
     let focusedContentView = WI._focusedContentView();
-    if (!focusedContentView)
-        return;
-
-    if (focusedContentView.supportsCustomFindBanner) {
+    if (focusedContentView?.supportsCustomFindBanner) {
         focusedContentView.handleFindNextShortcut();
         return;
     }
 
     let contentBrowser = WI._focusedOrVisibleContentBrowser();
-    if (!contentBrowser)
+    if (contentBrowser) {
+        contentBrowser.handleFindNextShortcut();
         return;
-
-    contentBrowser.handleFindNextShortcut();
+    }
 };
 
 WI._findPrevious = function(event)
 {
     let focusedContentView = WI._focusedContentView();
-    if (!focusedContentView)
-        return;
-
-    if (focusedContentView.supportsCustomFindBanner) {
+    if (focusedContentView?.supportsCustomFindBanner) {
         focusedContentView.handleFindPreviousShortcut();
         return;
     }
 
     let contentBrowser = WI._focusedOrVisibleContentBrowser();
-    if (!contentBrowser)
+    if (contentBrowser) {
+        contentBrowser.handleFindPreviousShortcut();
         return;
-
-    contentBrowser.handleFindPreviousShortcut();
+    }
 };
 
 WI._copy = function(event)

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js (260846 => 260847)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js	2020-04-28 21:43:13 UTC (rev 260847)
@@ -91,6 +91,11 @@
         WI.updateVisibilityState(visible);
     },
 
+    updateFindString: function(findString)
+    {
+        WI.updateFindString(findString);
+    },
+
     setDiagnosticLoggingAvailable: function(available)
     {
         if (WI.diagnosticController)

Modified: trunk/Source/WebInspectorUI/UserInterface/Test/Test.js (260846 => 260847)


--- trunk/Source/WebInspectorUI/UserInterface/Test/Test.js	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/Test.js	2020-04-28 21:43:13 UTC (rev 260847)
@@ -177,6 +177,7 @@
 WI.updateDockedState = () => {};
 WI.updateDockingAvailability = () => {};
 WI.updateVisibilityState = () => {};
+WI.updateFindString = () => {};
 
 // FIXME: <https://webkit.org/b/201149> Web Inspector: replace all uses of `window.*Agent` with a target-specific call
 (function() {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js (260846 => 260847)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ContentBrowser.js	2020-04-28 21:43:13 UTC (rev 260847)
@@ -246,28 +246,53 @@
 
     // Global ContentBrowser KeyboardShortcut handlers
 
-    handlePopulateFindShortcut()
+    handleFindStringUpdated()
     {
+        this._findBanner.searchQuery = WI.findString;
+
         let currentContentView = this.currentContentView;
-        if (!currentContentView || !currentContentView.supportsSearch)
-            return;
+        if (currentContentView?.supportsSearch)
+            currentContentView.performSearch(this._findBanner.searchQuery);
+    }
 
-        let searchQuery = currentContentView.searchQueryWithSelection();
-        if (!searchQuery)
-            return;
+    handlePopulateFindShortcut()
+    {
+        return this.currentContentView?.searchQueryWithSelection();
+    }
 
-        this._findBanner.searchQuery = searchQuery;
+    async handleFindNextShortcut()
+    {
+        if (this._findBanner.searchQuery !== WI.findString) {
+            let searchQuery = WI.findString;
+            this._findBanner.searchQuery = searchQuery;
 
-        currentContentView.performSearch(this._findBanner.searchQuery);
-    }
+            let currentContentView = this.currentContentView;
+            if (currentContentView?.supportsSearch) {
+                currentContentView.performSearch(this._findBanner.searchQuery);
+                await currentContentView.awaitEvent(WI.ContentView.Event.NumberOfSearchResultsDidChange);
+                if (this._findBanner.searchQuery !== searchQuery || this.currentContentView !== currentContentView)
+                    return;
+            }
+        }
 
-    handleFindNextShortcut()
-    {
         this.findBannerRevealNextResult(this._findBanner);
     }
 
-    handleFindPreviousShortcut()
+    async handleFindPreviousShortcut()
     {
+        if (this._findBanner.searchQuery !== WI.findString) {
+            let searchQuery = WI.findString;
+            this._findBanner.searchQuery = searchQuery;
+
+            let currentContentView = this.currentContentView;
+            if (currentContentView?.supportsSearch) {
+                currentContentView.performSearch(this._findBanner.searchQuery);
+                await currentContentView.awaitEvent(WI.ContentView.Event.NumberOfSearchResultsDidChange);
+                if (this._findBanner.searchQuery !== searchQuery || this.currentContentView !== currentContentView)
+                    return;
+            }
+        }
+
         this.findBannerRevealPreviousResult(this._findBanner);
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js (260846 => 260847)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LogContentView.js	2020-04-28 21:43:13 UTC (rev 260847)
@@ -296,24 +296,31 @@
         this._logViewController.requestClearMessages();
     }
 
-    handlePopulateFindShortcut()
+    handleFindStringUpdated()
     {
-        let searchQuery = this.searchQueryWithSelection();
-        if (!searchQuery)
-            return;
+        this._findBanner.searchQuery = WI.findString;
 
-        this._findBanner.searchQuery = searchQuery;
-
         this.performSearch(this._findBanner.searchQuery);
     }
 
+    handlePopulateFindShortcut()
+    {
+        return this.searchQueryWithSelection();
+    }
+
     handleFindNextShortcut()
     {
+        if (this._findBanner.searchQuery !== WI.findString)
+            this.handleFindStringUpdated();
+
         this.findBannerRevealNextResult(this._findBanner);
     }
 
     handleFindPreviousShortcut()
     {
+        if (this._findBanner.searchQuery !== WI.findString)
+            this.handleFindStringUpdated();
+
         this.findBannerRevealPreviousResult(this._findBanner);
     }
 

Modified: trunk/Source/WebKit/ChangeLog (260846 => 260847)


--- trunk/Source/WebKit/ChangeLog	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/ChangeLog	2020-04-28 21:43:13 UTC (rev 260847)
@@ -1,3 +1,42 @@
+2020-04-28  Devin Rousso  <[email protected]>
+
+        Web Inspector: find dialog does not populate search string from system find pasteboard
+        https://bugs.webkit.org/show_bug.cgi?id=113588
+        <rdar://problem/19281466>
+
+        Reviewed by Brian Burg.
+
+        * UIProcess/Inspector/mac/WKInspectorWKWebView.h:
+        * UIProcess/Inspector/mac/WKInspectorWKWebView.mm:
+        (-[WKInspectorWKWebView dealloc]): Added.
+        (-[WKInspectorWKWebView setInspectorWKWebViewDelegate:]):
+        (-[WKInspectorWKWebView becomeFirstResponder]): Added.
+        (-[WKInspectorWKWebView _handleWindowDidBecomeKey:]): Added.
+        * UIProcess/Inspector/mac/WKInspectorViewController.h:
+        * UIProcess/Inspector/mac/WKInspectorViewController.mm:
+        (-[WKInspectorViewController inspectorWKWebViewDidBecomeActive:]): Added.
+        * UIProcess/Inspector/WebInspectorProxy.h:
+        * UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
+        (-[WKWebInspectorProxyObjCAdapter inspectorViewControllerDidBecomeActive:]): Added.
+        (WebKit::WebInspectorProxy::didBecomeActive): Added.
+        * UIProcess/Inspector/RemoteWebInspectorProxy.h:
+        * UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm:
+        (-[WKRemoteWebInspectorProxyObjCAdapter inspectorWKWebViewDidBecomeActive:]): Added.
+        (WebKit::RemoteWebInspectorProxy::didBecomeActive): Added.
+        Add a new delegate call chain that notifies the inspector proxy about when the inspector web
+        view becomes active, at which point the inspector proxy can get the current find string and
+        sent it to the inspector page.
+
+        * WebProcess/Inspector/WebInspectorUI.messages.in:
+        * WebProcess/Inspector/WebInspectorUI.h:
+        * WebProcess/Inspector/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::updateFindString): Added.
+        * WebProcess/Inspector/RemoteWebInspectorUI.messages.in:
+        * WebProcess/Inspector/RemoteWebInspectorUI.h:
+        * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
+        (WebKit::RemoteWebInspectorUI::updateFindString): Added.
+        Pass along the new find string to the frontend via `InspectorFrontendAPI.updateFindString`.
+
 2020-04-28  Daniel Bates  <[email protected]>
 
         Remove unused WebPage::focusTextInputContext()

Modified: trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h	2020-04-28 21:43:13 UTC (rev 260847)
@@ -90,6 +90,8 @@
     WKWebView *webView() const;
 
     const WebCore::FloatRect& sheetRect() const { return m_sheetRect; }
+
+    void didBecomeActive();
 #endif
 
 #if PLATFORM(GTK)

Modified: trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h	2020-04-28 21:43:13 UTC (rev 260847)
@@ -113,6 +113,8 @@
     enum class InspectionTargetType { Local, Remote };
     static RetainPtr<NSWindow> createFrontendWindow(NSRect savedWindowFrame, InspectionTargetType);
 
+    void didBecomeActive();
+
     void updateInspectorWindowTitle() const;
     void inspectedViewFrameDidChange(CGFloat = 0);
     void windowFrameDidChange();

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm	2020-04-28 21:43:13 UTC (rev 260847)
@@ -28,6 +28,7 @@
 
 #if PLATFORM(MAC) && ENABLE(REMOTE_INSPECTOR)
 
+#import "GlobalFindInPageState.h"
 #import "RemoteWebInspectorProxyMessages.h"
 #import "RemoteWebInspectorUIMessages.h"
 #import "WKFrameInfo.h"
@@ -68,6 +69,11 @@
     return self;
 }
 
+- (void)inspectorWKWebViewDidBecomeActive:(WKInspectorViewController *)inspectorViewController
+{
+    _inspectorProxy->didBecomeActive();
+}
+
 - (void)inspectorViewControllerInspectorDidCrash:(WKInspectorViewController *)inspectorViewController
 {
     _inspectorProxy->closeFromCrash();
@@ -88,6 +94,11 @@
     return m_inspectorView.get().webView;
 }
 
+void RemoteWebInspectorProxy::didBecomeActive()
+{
+    m_inspectorPage->send(Messages::RemoteWebInspectorUI::UpdateFindString(WebKit::stringForFind()));
+}
+
 WebPageProxy* RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow()
 {
     m_objCAdapter = adoptNS([[WKRemoteWebInspectorProxyObjCAdapter alloc] initWithRemoteWebInspectorProxy:this]);

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.h	2020-04-28 21:43:13 UTC (rev 260847)
@@ -51,6 +51,7 @@
 
 @protocol WKInspectorViewControllerDelegate <NSObject>
 @optional
+- (void)inspectorViewControllerDidBecomeActive:(WKInspectorViewController *)inspectorViewController;
 - (void)inspectorViewControllerInspectorDidCrash:(WKInspectorViewController *)inspectorViewController;
 - (BOOL)inspectorViewControllerInspectorIsUnderTest:(WKInspectorViewController *)inspectorViewController;
 - (void)inspectorViewController:(WKInspectorViewController *)inspectorViewController willMoveToWindow:(NSWindow *)newWindow;

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorViewController.mm	2020-04-28 21:43:13 UTC (rev 260847)
@@ -235,6 +235,12 @@
 
 // MARK: WKInspectorWKWebViewDelegate methods
 
+- (void)inspectorWKWebViewDidBecomeActive:(WKInspectorWKWebView *)webView
+{
+    if ([_delegate respondsToSelector:@selector(inspectorViewControllerDidBecomeActive:)])
+        [_delegate inspectorViewControllerDidBecomeActive:self];
+}
+
 - (void)inspectorWKWebViewReload:(WKInspectorWKWebView *)webView
 {
     if (!_inspectedPage)

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorWKWebView.h (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorWKWebView.h	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorWKWebView.h	2020-04-28 21:43:13 UTC (rev 260847)
@@ -35,6 +35,7 @@
 
 @protocol WKInspectorWKWebViewDelegate
 @required
+- (void)inspectorWKWebViewDidBecomeActive:(WKInspectorWKWebView *)webView;
 - (void)inspectorWKWebViewReload:(WKInspectorWKWebView *)webView;
 - (void)inspectorWKWebViewReloadFromOrigin:(WKInspectorWKWebView *)webView;
 - (void)inspectorWKWebView:(WKInspectorWKWebView *)webView willMoveToWindow:(NSWindow *)newWindow;

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorWKWebView.mm (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorWKWebView.mm	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WKInspectorWKWebView.mm	2020-04-28 21:43:13 UTC (rev 260847)
@@ -35,6 +35,13 @@
     WeakObjCPtr<id <WKInspectorWKWebViewDelegate>> _inspectorWKWebViewDelegate;
 }
 
+- (void)dealloc
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil];
+
+    [super dealloc];
+}
+
 - (NSRect)_opaqueRectForWindowMoveWhenInTitlebar
 {
     // This convinces AppKit to allow window moves when clicking anywhere in the titlebar (top 22pt)
@@ -54,7 +61,13 @@
 
 - (void)setInspectorWKWebViewDelegate:(id <WKInspectorWKWebViewDelegate>)delegate
 {
+    if (!!_inspectorWKWebViewDelegate)
+        [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil];
+
     _inspectorWKWebViewDelegate = delegate;
+
+    if (!!_inspectorWKWebViewDelegate)
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_handleWindowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:nil];
 }
 
 - (IBAction)reload:(id)sender
@@ -79,6 +92,19 @@
     [self.inspectorWKWebViewDelegate inspectorWKWebViewDidMoveToWindow:self];
 }
 
+- (BOOL)becomeFirstResponder
+{
+    BOOL result = [super becomeFirstResponder];
+    [self.inspectorWKWebViewDelegate inspectorWKWebViewDidBecomeActive:self];
+    return result;
+}
+
+- (void)_handleWindowDidBecomeKey:(NSNotification *)notification
+{
+    if (notification.object == self.window)
+        [self.inspectorWKWebViewDelegate inspectorWKWebViewDidBecomeActive:self];
+}
+
 @end
 
 #endif

Modified: trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm (260846 => 260847)


--- trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm	2020-04-28 21:43:13 UTC (rev 260847)
@@ -28,6 +28,7 @@
 
 #if PLATFORM(MAC)
 
+#import "GlobalFindInPageState.h"
 #import "WKInspectorPrivateMac.h"
 #import "WKInspectorViewController.h"
 #import "WKViewInternal.h"
@@ -163,6 +164,12 @@
 
 // MARK: WKInspectorViewControllerDelegate methods
 
+- (void)inspectorViewControllerDidBecomeActive:(WKInspectorViewController *)inspectorViewController
+{
+    if (_inspectorProxy)
+        _inspectorProxy->didBecomeActive();
+}
+
 - (void)inspectorViewControllerInspectorDidCrash:(WKInspectorViewController *)inspectorViewController
 {
     if (_inspectorProxy)
@@ -191,6 +198,11 @@
 namespace WebKit {
 using namespace WebCore;
 
+void WebInspectorProxy::didBecomeActive()
+{
+    m_inspectorPage->send(Messages::WebInspectorUI::UpdateFindString(WebKit::stringForFind()));
+}
+
 void WebInspectorProxy::attachmentViewDidChange(NSView *oldView, NSView *newView)
 {
     [[NSNotificationCenter defaultCenter] removeObserver:m_objCAdapter.get() name:NSViewFrameDidChangeNotification object:oldView];

Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp (260846 => 260847)


--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp	2020-04-28 21:43:13 UTC (rev 260847)
@@ -67,6 +67,11 @@
     m_frontendAPIDispatcher.dispatchCommand("setDockingUnavailable"_s, true);
 }
 
+void RemoteWebInspectorUI::updateFindString(const String& findString)
+{
+    m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, findString);
+}
+
 void RemoteWebInspectorUI::didSave(const String& url)
 {
     m_frontendAPIDispatcher.dispatchCommand("savedURL"_s, url);

Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h (260846 => 260847)


--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h	2020-04-28 21:43:13 UTC (rev 260847)
@@ -50,6 +50,7 @@
 
     // Called by RemoteWebInspectorUI messages
     void initialize(DebuggableInfoData&&, const String& backendCommandsURL);
+    void updateFindString(const String&);
     void didSave(const String& url);
     void didAppend(const String& url);
     void sendMessageToFrontend(const String&);

Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.messages.in (260846 => 260847)


--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.messages.in	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.messages.in	2020-04-28 21:43:13 UTC (rev 260847)
@@ -23,6 +23,8 @@
 messages -> RemoteWebInspectorUI {
     Initialize(struct WebKit::DebuggableInfoData debuggableInfo, String backendCommandsURL)
 
+    UpdateFindString(String findString)
+
 #if ENABLE(INSPECTOR_TELEMETRY)
     SetDiagnosticLoggingAvailable(bool available)
 #endif

Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp (260846 => 260847)


--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp	2020-04-28 21:43:13 UTC (rev 260847)
@@ -269,6 +269,11 @@
     m_frontendAPIDispatcher.dispatchCommand("setIsVisible"_s, visible);
 }
 
+void WebInspectorUI::updateFindString(const String& findString)
+{
+    m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, findString);
+}
+
 void WebInspectorUI::changeAttachedWindowHeight(unsigned height)
 {
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetAttachedWindowHeight(height), m_inspectedPageIdentifier);

Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h (260846 => 260847)


--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h	2020-04-28 21:43:13 UTC (rev 260847)
@@ -79,6 +79,8 @@
 
     void setIsVisible(bool);
 
+    void updateFindString(const String&);
+
     void didSave(const String& url);
     void didAppend(const String& url);
 

Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.messages.in (260846 => 260847)


--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.messages.in	2020-04-28 21:31:34 UTC (rev 260846)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.messages.in	2020-04-28 21:43:13 UTC (rev 260847)
@@ -30,6 +30,7 @@
     Detached()
     SetDockingUnavailable(bool unavailable)
     SetIsVisible(bool visible)
+    UpdateFindString(String findString)
 
 #if ENABLE(INSPECTOR_TELEMETRY)
     SetDiagnosticLoggingAvailable(bool available)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to