Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7aa2ee380a72ee199901e6eaeec3006c78d13be8
      
https://github.com/WebKit/WebKit/commit/7aa2ee380a72ee199901e6eaeec3006c78d13be8
  Author: Richard Robinson <[email protected]>
  Date:   2025-07-24 (Thu, 24 Jul 2025)

  Changed paths:
    M Source/WebCore/PAL/pal/spi/cocoa/WritingToolsSPI.h
    M Source/WebCore/PAL/pal/spi/cocoa/WritingToolsUISPI.h
    M Source/WebKit/Configurations/WebKit.xcconfig
    A Source/WebKit/Modules/Internal/WebKitInternalCxx.h
    M Source/WebKit/Modules/Internal/module.modulemap
    M Source/WebKit/Platform/IPC/Connection.h
    M Source/WebKit/Platform/IPC/ConnectionHandle.h
    M Source/WebKit/Platform/IPC/Decoder.h
    M Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h
    M Source/WebKit/Platform/IPC/StreamConnectionBuffer.h
    M Source/WebKit/Platform/LogClient.h
    M Source/WebKit/Scripts/webkit/messages.py
    M Source/WebKit/Scripts/webkit/tests/MessageNames.h
    M Source/WebKit/UIProcess/API/Cocoa/WKContextMenuElementInfoAdapter.swift
    M Source/WebKit/UIProcess/API/Cocoa/WebKitSwiftOverlay.swift
    M Source/WebKit/UIProcess/API/Swift/URLSchemeHandler.swift
    M Source/WebKit/UIProcess/API/Swift/WebPage+BackForwardList.swift
    M Source/WebKit/UIProcess/API/Swift/WebPage+Configuration.swift
    M Source/WebKit/UIProcess/API/Swift/WebPage+DialogPresenting.swift
    M Source/WebKit/UIProcess/API/Swift/WebPage.swift
    M Source/WebKit/UIProcess/Cocoa/Foundation+Extras.swift
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  [Swift in WebKit] Add initial support for Swift-Cxx interop in WebKit
https://bugs.webkit.org/show_bug.cgi?id=296393
rdar://156525628

Reviewed by Abrar Rahman Protyasha.

Set `SWIFT_OBJC_INTEROP_MODE` to `objcxx` in WebKit so that Swift code in 
WebKit can access C++.

Specifically, any header file that is part of a clang module (such as 
WebKit_Internal
and WebKit_Internal_Cxx) can be accessed from Swift. However, each of those 
files need
to be compatible with modularization, and must include all headers they use 
(and cannot
for example depend on transitive imports).

Currently, enable this only for macOS due to some module issues that affect iOS 
and Catalyst.
Once these are resolved, the switch can be flipped for those platforms.

* Source/WebCore/PAL/pal/spi/cocoa/WritingToolsSPI.h:
* Source/WebCore/PAL/pal/spi/cocoa/WritingToolsUISPI.h:

Due to an issue in the header files of WritingTools, an error happens if they 
are
attempted to be accessed as modularized headers. To workaround this, the imports
themselves are removed in favor of just forward declaring the symbols, just 
like the
open source build.

In doing so, this reveals some minor differences between the forward 
declarations and the actual header contents, so those are fixed as well.

* Source/WebCore/platform/LogClient.h:
* Source/WebKit/Configurations/WebKit.xcconfig:

Set `SWIFT_OBJC_INTEROP_MODE = objcxx;`, which overrides the 
`SWIFT_OBJC_INTEROP_MODE =
objc` value in Base.xcconfig so that WebKit can use the interop without 
WebKitSwift or
others needing it.

* Source/WebKit/Modules/Internal/WebKitInternalCxx.h: Added.
* Source/WebKit/Modules/Internal/module.modulemap:

Add a new module for non-ObjC C++ headers, WebKit_Internal_Cxx.

* Source/WebKit/Platform/IPC/Connection.h:
* Source/WebKit/Platform/IPC/ConnectionHandle.h:
* Source/WebKit/Platform/IPC/Decoder.h:
* Source/WebKit/Platform/IPC/MessageReceiveQueueMap.h:
* Source/WebKit/Platform/IPC/StreamConnectionBuffer.h:
* Source/WebKit/Platform/LogClient.h:
* Source/WebKit/Scripts/webkit/messages.py:
(generate_message_names_header):

These headers are dependencies of some file in the WebKit_Internal or
WebKit_Internal_Cxx clang modules. As a result, add any imports that were 
previously
absent due to having been imported transitively.

* Source/WebKit/UIProcess/API/Cocoa/WKContextMenuElementInfoAdapter.swift:
* Source/WebKit/UIProcess/API/Cocoa/WebKitSwiftOverlay.swift:
(WKWebView.find(_:configuration:)):
(WKWebView.evaluateJavaScript(_:in:contentWorld:)):
* Source/WebKit/UIProcess/API/Swift/URLSchemeHandler.swift:
* Source/WebKit/UIProcess/API/Swift/WebPage+BackForwardList.swift:
* Source/WebKit/UIProcess/API/Swift/WebPage+Configuration.swift:
(Configuration.applicationNameForUserAgent):
* Source/WebKit/UIProcess/API/Swift/WebPage+DialogPresenting.swift:
(DialogPresenting.handleJavaScriptAlert(_:initiatedBy:)):
(DialogPresenting.handleJavaScriptConfirm(_:initiatedBy:)):
(WebPage.handleJavaScriptAlert(_:initiatedBy:)):
(WebPage.handleJavaScriptConfirm(_:initiatedBy:)):
* Source/WebKit/UIProcess/API/Swift/WebPage.swift:
(url):
(title):
(customUserAgent):
(load(_:)):
(load(_:mimeType:characterEncoding:baseURL:)):
(load(_:baseURL:)):
(load(simulatedRequest:responseHTML:)):
* Source/WebKit/UIProcess/Cocoa/Foundation+Extras.swift:

Now that Swift can access C++, there are some naming conflicts with 
`Swift.String` with
`wtf/String`, and `Foundation.URL` with `wtf/URL`. To resolve this, a typealias 
is
defined so that the Swift versions take precedence in Swift. For API 
declarations, the
fully qualified symbol name must be used because the typealias itself is not 
public and
should not be.

* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/297841@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

Reply via email to