Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e492299027dcbe5535755c39f7cf48e6a4bfc590
https://github.com/WebKit/WebKit/commit/e492299027dcbe5535755c39f7cf48e6a4bfc590
Author: Richard Robinson <[email protected]>
Date: 2026-08-05 (Wed, 05 Aug 2026)
Changed paths:
M Source/WebKit/Platform/unix/EnvironmentUtilities.h
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
M Source/WebKit/UIProcess/API/Swift/WebPage+SPI.swift
M Source/WebKit/UIProcess/API/Swift/WebPage.swift
M Source/WebKit/UIProcess/API/cpp/WKCast.h
M Source/WebKit/UIProcess/API/cpp/WKRetainPtr.h
M Source/WebKit/UIProcess/Cocoa/WKUIDelegateAdapter.swift
M Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h
M
Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h
M
Source/WebKit/_WebKit_SwiftUI/API/View+WebViewModifiers.swift
M Source/WebKit/_WebKit_SwiftUI/API/WebView.swift
M
Source/WebKit/_WebKit_SwiftUI/Implementation/EnvironmentValues+Extras.swift
M Source/WebKit/_WebKit_SwiftUI/Implementation/ViewModifierContexts.swift
M Source/WebKit/_WebKit_SwiftUI/Implementation/WebViewRepresentable.swift
M Tools/TestWebKitAPI/Helpers/cocoa/SwiftUI+Extras.swift
M Tools/TestWebKitAPI/Tests/WebKit/WebPage/WebViewTests.swift
Log Message:
-----------
[SwiftUI WebKit API] WebPage needs the WKUIDelegatePrivate attachment
lifecycle callbacks (didInsertAttachment:withSource:, didRemoveAttachment:,
didInvalidateDataForAttachment:)
https://bugs.webkit.org/show_bug.cgi?id=321040
rdar://184057419
Reviewed by Wenson Hsieh.
Add a few SPIs on WebView and WebPage to make dealing with attachments easier:
For handling the attachment lifecycle, a new view modifier SPI is introduced:
```
extension WebView {
public
struct AttachmentActivityPhase {
public enum Kind: Sendable {
case inserted(_ source: String)
case removed
case dataInvalidated
}
public var attachment: _WKAttachment { get }
public var kind: Kind { get }
}
}
extension View {
public nonisolated func webViewOnAttachmentActivityPhase(
_ action: @escaping @MainActor (_ phase:
WebView.AttachmentActivityPhase) -> Void
) -> some View
}
```
On WebPage, new SPI is added to create an attachment and retrieve an attachment:
```
extension WebPage {
public func insertAttachment(fileWrapper: FileWrapper, contentType:
Swift.String?) async -> _WKAttachment?
public func attachment(id: Swift.String) -> _WKAttachment?
}
```
Test: Tools/TestWebKitAPI/Tests/WebKit/WebPage/WebViewTests.swift
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView
_insertAttachmentWithFileWrapperAsync:contentType:completion:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:
* Source/WebKit/UIProcess/API/Swift/WebPage+SPI.swift:
(AttachmentLifecycleListeners.didRemoveAttachment):
(AttachmentLifecycleListeners.didInsertAttachment):
(AttachmentLifecycleListeners.didInvalidateDataForAttachment):
(WebPage.insertAttachment(_:contentType:)):
(WebPage.attachment(_:)):
(WebPage.setMenuBuilder(_:)): Deleted.
* Source/WebKit/UIProcess/API/Swift/WebPage.swift:
* Source/WebKit/UIProcess/Cocoa/WKUIDelegateAdapter.swift:
(WKUIDelegateAdapter._webView(_:didRemove:)):
(WKUIDelegateAdapter._webView(_:didInsert:withSource:)):
(WKUIDelegateAdapter._webView(_:didInvalidateDataFor:)):
* Source/WebKit/_WebKit_SwiftUI/API/View+WebViewModifiers.swift:
* Source/WebKit/_WebKit_SwiftUI/API/WebView.swift:
* Source/WebKit/_WebKit_SwiftUI/Implementation/EnvironmentValues+Extras.swift:
(EnvironmentValues.webViewOnAttachmentActivityPhaseContext):
*
Source/WebKit/_WebKit_SwiftUI/Implementation/ViewModifierContexts.swift:
* Source/WebKit/_WebKit_SwiftUI/Implementation/WebViewRepresentable.swift:
(WebViewRepresentable.updatePlatformView(_:context:)):
* Tools/TestWebKitAPI/Helpers/cocoa/SwiftUI+Extras.swift:
(render(@ViewBuilder rootView: () -> some View:)):
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/WebViewTests.swift:
(Attachments.inserted):
(Attachments.removed):
(TestView.body):
(WebViewTests.onAttachmentActivityPhaseAffectsListeners):
(ViewModel.isEditable): Deleted.
(ViewModel.viewportWidth): Deleted.
(ViewModel.viewportInitialScale): Deleted.
Canonical link:
https://flagged.apple.com:443/proxy?t2=DD6o6q7Dz6&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE4NjcyQG1haW4=&emid=0607133d-3a6f-4013-8b23-c5fe9925b896&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications