Title: [295095] trunk
Revision
295095
Author
[email protected]
Date
2022-06-01 10:32:05 -0700 (Wed, 01 Jun 2022)

Log Message

Revert "Allow decidePolicyForNavigation* decisionHandlers to be called on non-main runloops"

Unreviewed, this reverts commit 251175@main.

Canonical link: https://commits.webkit.org/251190@main

Modified Paths

Diff

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (295094 => 295095)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2022-06-01 17:26:14 UTC (rev 295094)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2022-06-01 17:32:05 UTC (rev 295095)
@@ -575,20 +575,13 @@
     };
 
     if (delegateHasWebpagePreferences) {
-        auto decisionHandler = [decisionHandlerWithPreferencesOrPolicies = WTFMove(decisionHandlerWithPreferencesOrPolicies)] (WKNavigationActionPolicy actionPolicy, WKWebpagePreferences *preferences) mutable {
-            ensureOnMainRunLoop([decisionHandlerWithPreferencesOrPolicies = WTFMove(decisionHandlerWithPreferencesOrPolicies), actionPolicy, retainedPreferences = RetainPtr { preferences }] () mutable {
-                decisionHandlerWithPreferencesOrPolicies(actionPolicy, retainedPreferences.get());
-            });
-        };
         if (m_navigationState->m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionWithPreferencesDecisionHandler)
-            [navigationDelegate webView:m_navigationState->m_webView decidePolicyForNavigationAction:wrapper(navigationAction) preferences:wrapper(defaultWebsitePolicies) decisionHandler:makeBlockPtr(WTFMove(decisionHandler)).get()];
+            [navigationDelegate webView:m_navigationState->m_webView decidePolicyForNavigationAction:wrapper(navigationAction) preferences:wrapper(defaultWebsitePolicies) decisionHandler:makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies)).get()];
         else
-            [(id<WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState->m_webView decidePolicyForNavigationAction:wrapper(navigationAction) preferences:wrapper(defaultWebsitePolicies) userInfo:userInfo ? static_cast<id<NSSecureCoding>>(userInfo->wrapper()) : nil decisionHandler:makeBlockPtr(WTFMove(decisionHandler)).get()];
+            [(id <WKNavigationDelegatePrivate>)navigationDelegate _webView:m_navigationState->m_webView decidePolicyForNavigationAction:wrapper(navigationAction) preferences:wrapper(defaultWebsitePolicies) userInfo:userInfo ? static_cast<id<NSSecureCoding>>(userInfo->wrapper()) : nil decisionHandler:makeBlockPtr(WTFMove(decisionHandlerWithPreferencesOrPolicies)).get()];
     } else {
         auto decisionHandler = [decisionHandlerWithPreferencesOrPolicies = WTFMove(decisionHandlerWithPreferencesOrPolicies)] (WKNavigationActionPolicy actionPolicy) mutable {
-            ensureOnMainRunLoop([decisionHandlerWithPreferencesOrPolicies = WTFMove(decisionHandlerWithPreferencesOrPolicies), actionPolicy] () mutable {
-                decisionHandlerWithPreferencesOrPolicies(actionPolicy, nil);
-            });
+            decisionHandlerWithPreferencesOrPolicies(actionPolicy, nil);
         };
         [navigationDelegate webView:m_navigationState->m_webView decidePolicyForNavigationAction:wrapper(navigationAction) decisionHandler:makeBlockPtr(WTFMove(decisionHandler)).get()];
     }
@@ -661,26 +654,24 @@
         return;
 
     auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), @selector(webView:decidePolicyForNavigationResponse:decisionHandler:));
-    [navigationDelegate webView:m_navigationState->m_webView decidePolicyForNavigationResponse:wrapper(navigationResponse) decisionHandler:makeBlockPtr([localListener = WTFMove(listener), checker = WTFMove(checker)](WKNavigationResponsePolicy responsePolicy) mutable {
-        ensureOnMainRunLoop([responsePolicy, checker = WTFMove(checker), localListener = WTFMove(localListener)] {
-            if (checker->completionHandlerHasBeenCalled())
-                return;
-            checker->didCallCompletionHandler();
+    [navigationDelegate webView:m_navigationState->m_webView decidePolicyForNavigationResponse:wrapper(navigationResponse) decisionHandler:makeBlockPtr([localListener = WTFMove(listener), checker = WTFMove(checker)](WKNavigationResponsePolicy responsePolicy) {
+        if (checker->completionHandlerHasBeenCalled())
+            return;
+        checker->didCallCompletionHandler();
 
-            switch (responsePolicy) {
-            case WKNavigationResponsePolicyAllow:
-                localListener->use();
-                break;
+        switch (responsePolicy) {
+        case WKNavigationResponsePolicyAllow:
+            localListener->use();
+            break;
 
-            case WKNavigationResponsePolicyCancel:
-                localListener->ignore();
-                break;
+        case WKNavigationResponsePolicyCancel:
+            localListener->ignore();
+            break;
 
-            case WKNavigationResponsePolicyDownload:
-                localListener->download();
-                break;
-            }
-        });
+        case WKNavigationResponsePolicyDownload:
+            localListener->download();
+            break;
+        }
     }).get()];
 }
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAction.mm (295094 => 295095)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAction.mm	2022-06-01 17:26:14 UTC (rev 295094)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/NavigationAction.mm	2022-06-01 17:32:05 UTC (rev 295095)
@@ -215,31 +215,3 @@
     [webView loadHTMLString:html baseURL:nil];
     TestWebKitAPI::Util::run(&done);
 }
-
-TEST(WKNavigationAction, NonMainThread)
-{
-    TestWebKitAPI::HTTPServer server({
-        { "/"_s, { "hi"_s } },
-    });
-
-    auto delegate = adoptNS([TestNavigationDelegate new]);
-    auto webView = adoptNS([WKWebView new]);
-    [webView setNavigationDelegate:delegate.get()];
-    __block bool done = false;
-    delegate.get().decidePolicyForNavigationAction = ^(WKNavigationAction *action, void (^completionHandler)(WKNavigationActionPolicy)) {
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            completionHandler(WKNavigationActionPolicyAllow);
-        });
-    };
-    delegate.get().decidePolicyForNavigationResponse = ^(WKNavigationResponse *action, void (^completionHandler)(WKNavigationResponsePolicy)) {
-        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            completionHandler(WKNavigationResponsePolicyAllow);
-        });
-    };
-    delegate.get().didFinishNavigation = ^(WKWebView *, WKNavigation *) {
-        done = true;
-    };
-
-    [webView loadRequest:server.request()];
-    TestWebKitAPI::Util::run(&done);
-}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to