Web Inspector: WebInspectorProxy releases WKWebInspectorProxyObjCAdapter without...
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Apr 2018 23:03:44 +0000 (23:03 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Apr 2018 23:03:44 +0000 (23:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=184865
<rdar://problem/37764960>

Reviewed by Brian Burg.

Replace the early return removed in https://bugs.webkit.org/show_bug.cgi?id=177661,
so that WKWebInspectorProxyObjCAdapter and the view controller can be reused
when reopening the Inspector while the WebView is still alive.

* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::platformCreateFrontendPage):

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

Source/WebKit/ChangeLog
Source/WebKit/UIProcess/mac/WebInspectorProxyMac.mm

index 335c962..7df4961 100644 (file)
@@ -1,3 +1,18 @@
+2018-04-22  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: WebInspectorProxy releases WKWebInspectorProxyObjCAdapter without removing corresponding observer
+        https://bugs.webkit.org/show_bug.cgi?id=184865
+        <rdar://problem/37764960>
+
+        Reviewed by Brian Burg.
+
+        Replace the early return removed in https://bugs.webkit.org/show_bug.cgi?id=177661,
+        so that WKWebInspectorProxyObjCAdapter and the view controller can be reused
+        when reopening the Inspector while the WebView is still alive.
+
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::platformCreateFrontendPage):
+
 2018-04-22  Paul Knight  <pknight@apple.com>
 
         Add -[WKInputDelegate _webView:decidePolicyForFocusedElement:] so clients can request default focusing behavior
index a8bfc05..3cfab99 100644 (file)
@@ -217,6 +217,11 @@ WebPageProxy* WebInspectorProxy::platformCreateFrontendPage()
 
     m_closeFrontendAfterInactivityTimer.stop();
 
+    if (m_inspectorViewController) {
+        ASSERT(m_objCAdapter);
+        return [m_inspectorViewController webView]->_page.get();
+    }
+
     m_objCAdapter = adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
     NSView *inspectedView = inspectedPage()->inspectorAttachmentView();
     [[NSNotificationCenter defaultCenter] addObserver:m_objCAdapter.get() selector:@selector(inspectedViewFrameDidChange:) name:NSViewFrameDidChangeNotification object:inspectedView];