Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: fc7a43367612f0e0aed65c9e7ceb9539df13b800
https://github.com/WebKit/WebKit/commit/fc7a43367612f0e0aed65c9e7ceb9539df13b800
Author: Richard Robinson <[email protected]>
Date: 2025-10-20 (Mon, 20 Oct 2025)
Changed paths:
M Source/JavaScriptCore/API/tests/testapi.mm
M Source/WTF/wtf/CompletionHandler.h
M Source/WTF/wtf/Function.h
M Source/WTF/wtf/text/StringImpl.h
M Source/WebCore/platform/ios/wak/WebCoreThread.mm
M Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
M Tools/TestWebKitAPI/Configurations/Base.xcconfig
M Tools/TestWebKitAPI/Configurations/TestWebKitAPIBundle.xcconfig
M Tools/TestWebKitAPI/Configurations/TestWebKitAPILibrary.xcconfig
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
A Tools/TestWebKitAPI/Tests/WTF/cocoa/SwiftCxxInteropTestbed.cpp
A Tools/TestWebKitAPI/Tests/WTF/cocoa/SwiftCxxInteropTestbed.h
A Tools/TestWebKitAPI/Tests/WTF/cocoa/SwiftCxxInteropTests.swift
M Tools/TestWebKitAPI/Tests/WebKit Swift/Foundation+Extras.swift
M Tools/TestWebKitAPI/Tests/WebKit
Swift/TestWebKitAPIBundle-Bridging-Header.h
M Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteMixedContent.mm
M Tools/TestWebKitAPI/Tests/WebKitCocoa/SmartListsSupport.swift
M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
Log Message:
-----------
It should not be possible to make a WTF::Function or WTF::CompletionHandler
from an Objective-C block in Objective-C++
https://bugs.webkit.org/show_bug.cgi?id=300962
rdar://162838519
Reviewed by Abrar Rahman Protyasha.
It's currently possible to implicitly convert an Objective-C block to a
WTF::Function or WTF::CompletionHandler. This
behavior leads to some inconsistencies; while the vast, vast majority of uses
use lambdas converted to these types, there
are a handful that use blocks, for no specific reason.
Address these inconsistencies by changing Function.h and CompletionHandler.h to
have a new overloaded initializer that
accepts a block, and then delete that initializer. The result of this is that
if a client tries to create one of these
types from a block, it will choose this intiializer during overload resolution,
and then fail to compile due to the fact
that it is deleted.
This only applies to Objective-C++, since Swift cannot create C++ lambdas
itself, so there is no room for ambiguity or inconsistency.
* Source/JavaScriptCore/API/tests/testapi.mm:
(parallelPromiseResolveTest):
* Source/WebCore/platform/ios/wak/WebCoreThread.mm:
(WebThreadRunOnMainThread):
* Source/WebCore/platform/network/cocoa/WebCoreNSURLSession.mm:
(-[WebCoreNSURLSession resetWithCompletionHandler:]):
(-[WebCoreNSURLSession flushWithCompletionHandler:]):
(-[WebCoreNSURLSession getTasksWithCompletionHandler:]):
(-[WebCoreNSURLSession getAllTasksWithCompletionHandler:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView closeAllMediaPresentationsWithCompletionHandler:]):
* Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitialize):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/PasteMixedContent.mm:
(TestWebKitAPI::TEST(PasteMixedContent, PasteOneOrMoreURLs)):
- Fix inconsistent uses of blocks as WTF::Function.
* Source/WTF/wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* Source/WTF/wtf/Function.h:
(WTF::Detail::CallableWrapperAllocatorBase::~CallableWrapperAllocatorBase):
(WTF::Function<Out):
- Make it impossible to create these types from blocks in Objective-C++
- Introduce a new base type so that linkage from Swift can work properly
* Source/WTF/wtf/text/StringImpl.h:
- Add missing include
* Tools/TestWebKitAPI/Configurations/Base.xcconfig:
* Tools/TestWebKitAPI/Configurations/TestWebKitAPIBundle.xcconfig:
* Tools/TestWebKitAPI/Configurations/TestWebKitAPILibrary.xcconfig:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WTF/cocoa/SwiftCxxInteropTestbed.cpp: Copied from
Tools/TestWebKitAPI/Tests/WebKit Swift/
stWebKitAPIBundle-Bridging-Header.h.
(SwiftCxxInteropTestbed::callIntBoolFunction):
(SwiftCxxInteropTestbed::callIntCompletionHandler):
* Tools/TestWebKitAPI/Tests/WTF/cocoa/SwiftCxxInteropTestbed.h: Copied from
Tools/TestWebKitAPI/Tests/WebKit Swift/
stWebKitAPIBundle-Bridging-Header.h.
* Tools/TestWebKitAPI/Tests/WTF/cocoa/SwiftCxxInteropTests.swift: Copied from
Tools/TestWebKitAPI/Tests/WebKit Swift/Foundation+Extras.swift.
(SwiftCxxInteropTests.wtfFunctionCanBeInvokedFromSwift):
(SwiftCxxInteropTests.wtfCompletionHandlerCanBeInvokedFromSwift):
- Test interop between Swift and WTF C++.
* Tools/TestWebKitAPI/Tests/WebKit Swift/Foundation+Extras.swift:
* Tools/TestWebKitAPI/Tests/WebKit Swift/TestWebKitAPIBundle-Bridging-Header.h:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SmartListsSupport.swift:
(SmartListsTestSelectionConfiguration.caretSelection(withPath:offset:)):
* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
- Minor clean-up
Canonical link: https://commits.webkit.org/301813@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes