[Cocoa] Expose UIDelegate::UIClient::close via WKUIDelegate
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Jun 2015 16:18:04 +0000 (16:18 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 17 Jun 2015 16:18:04 +0000 (16:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145957

Reviewed by Darin Adler.

Source/WebKit2:

* UIProcess/API/Cocoa/WKUIDelegate.h: Added -webViewDidClose: to the protocol.
* UIProcess/Cocoa/UIDelegate.h: Added a webViewDidClose boolean to the delegate methods struct.
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate): Initialize the webViewDidClose boolean.
(WebKit::UIDelegate::UIClient::close): Changed to call the new delegate method. Left behind
code that calls the old private method if it’s implemented.

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm:
(-[OpenAndCloseWindowUIDelegate webViewDidClose:]): Renamed from -_webViewClose:.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegate.h
Source/WebKit2/UIProcess/Cocoa/UIDelegate.h
Source/WebKit2/UIProcess/Cocoa/UIDelegate.mm
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm

index 56cf81a..814fe3c 100644 (file)
@@ -1,3 +1,17 @@
+2015-06-17  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Expose UIDelegate::UIClient::close via WKUIDelegate
+        https://bugs.webkit.org/show_bug.cgi?id=145957
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/Cocoa/WKUIDelegate.h: Added -webViewDidClose: to the protocol.
+        * UIProcess/Cocoa/UIDelegate.h: Added a webViewDidClose boolean to the delegate methods struct.
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::setDelegate): Initialize the webViewDidClose boolean.
+        (WebKit::UIDelegate::UIClient::close): Changed to call the new delegate method. Left behind
+        code that calls the old private method if it’s implemented.
+
 2015-06-17  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER doesn't disable memory cache when set before the web process is launched
index fa734a6..98c2d70 100644 (file)
@@ -57,6 +57,13 @@ WK_ASSUME_NONNULL_BEGIN
  */
 - (WK_NULLABLE WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures;
 
+/*! @abstract Notifies your app that the DOM window object's close() method completed successfully.
+  @param webView The web view invoking the delegate method.
+  @discussion Your app should remove the web view from the view hierarchy and update
+  the UI as needed, such as by closing the containing browser tab or window.
+  */
+- (void)webViewDidClose:(WKWebView *)webView;
+
 /*! @abstract Displays a JavaScript alert panel.
  @param webView The web view invoking the delegate method.
  @param message The message to display.
index 637baf0..8218809 100644 (file)
@@ -88,6 +88,7 @@ private:
         bool webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler : 1;
         bool webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded : 1;
         bool webViewPrintFrame : 1;
+        bool webViewDidClose : 1;
         bool webViewClose : 1;
         bool webViewFullscreenMayReturnToInline : 1;
         bool webViewDidEnterFullscreen : 1;
index 8175a7e..5b29cc5 100644 (file)
@@ -71,6 +71,7 @@ void UIDelegate::setDelegate(id <WKUIDelegate> delegate)
     m_delegateMethods.webViewDecideDatabaseQuotaForSecurityOriginCurrentQuotaCurrentOriginUsageCurrentDatabaseUsageExpectedUsageDecisionHandler = [delegate respondsToSelector:@selector(_webView:decideDatabaseQuotaForSecurityOrigin:currentQuota:currentOriginUsage:currentDatabaseUsage:expectedUsage:decisionHandler:)];
     m_delegateMethods.webViewDecideWebApplicationCacheQuotaForSecurityOriginCurrentQuotaTotalBytesNeeded = [delegate respondsToSelector:@selector(_webView:decideWebApplicationCacheQuotaForSecurityOrigin:currentQuota:totalBytesNeeded:decisionHandler:)];
     m_delegateMethods.webViewPrintFrame = [delegate respondsToSelector:@selector(_webView:printFrame:)];
+    m_delegateMethods.webViewDidClose = [delegate respondsToSelector:@selector(webViewDidClose:)];
     m_delegateMethods.webViewClose = [delegate respondsToSelector:@selector(_webViewClose:)];
     m_delegateMethods.webViewFullscreenMayReturnToInline = [delegate respondsToSelector:@selector(_webViewFullscreenMayReturnToInline:)];
     m_delegateMethods.webViewDidEnterFullscreen = [delegate respondsToSelector:@selector(_webViewDidEnterFullscreen:)];
@@ -232,14 +233,23 @@ void UIDelegate::UIClient::printFrame(WebKit::WebPageProxy*, WebKit::WebFramePro
 
 void UIDelegate::UIClient::close(WebKit::WebPageProxy*)
 {
-    if (!m_uiDelegate.m_delegateMethods.webViewClose)
+    if (m_uiDelegate.m_delegateMethods.webViewClose) {
+        auto delegate = m_uiDelegate.m_delegate.get();
+        if (!delegate)
+            return;
+
+        [(id <WKUIDelegatePrivate>)delegate _webViewClose:m_uiDelegate.m_webView];
+        return;
+    }
+
+    if (!m_uiDelegate.m_delegateMethods.webViewDidClose)
         return;
 
     auto delegate = m_uiDelegate.m_delegate.get();
     if (!delegate)
         return;
 
-    [(id <WKUIDelegatePrivate>)delegate _webViewClose:m_uiDelegate.m_webView];
+    [delegate webViewDidClose:m_uiDelegate.m_webView];
 }
 
 void UIDelegate::UIClient::fullscreenMayReturnToInline(WebKit::WebPageProxy*)
index bda739a..f4378a6 100644 (file)
@@ -1,3 +1,13 @@
+2015-06-17  Dan Bernstein  <mitz@apple.com>
+
+        [Cocoa] Expose UIDelegate::UIClient::close via WKUIDelegate
+        https://bugs.webkit.org/show_bug.cgi?id=145957
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/OpenAndCloseWindow.mm:
+        (-[OpenAndCloseWindowUIDelegate webViewDidClose:]): Renamed from -_webViewClose:.
+
 2015-06-15  Chris Fleizach  <cfleizach@apple.com>
 
         AX:  iOS accessibility tests are not running because we need WKTR support
index 6cd2e2b..b8f5211 100644 (file)
@@ -45,7 +45,7 @@ static RetainPtr<OpenAndCloseWindowUIDelegate> sharedUIDelegate;
 
 @implementation OpenAndCloseWindowUIDelegate
 
-- (void)_webViewClose:(WKWebView *)webView
+- (void)webViewDidClose:(WKWebView *)webView
 {
     EXPECT_EQ(openedWebView, webView);
     isDone = true;