[webkit-changes] [WebKit/WebKit] 9240ea: [SwiftUI] Provide ability for clients to tell when...

Richard Robinson noreply at github.com
Mon Feb 24 12:32:31 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9240eac1e801f2fe5f1d0bb30ef1a7066a762b78
      https://github.com/WebKit/WebKit/commit/9240eac1e801f2fe5f1d0bb30ef1a7066a762b78
  Author: Richard Robinson <richard_robinson2 at apple.com>
  Date:   2025-02-24 (Mon, 24 Feb 2025)

  Changed paths:
    M Source/WebKit/Modules/Internal/WebKitInternal.h
    M Source/WebKit/SourcesCocoa.txt
    A Source/WebKit/UIProcess/API/Cocoa/WKScrollGeometry.h
    A Source/WebKit/UIProcess/API/Cocoa/WKScrollGeometry.mm
    A Source/WebKit/UIProcess/API/Cocoa/WKUIDelegateInternal.h
    M Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    A Source/WebKit/UIProcess/API/Swift/WKScrollGeometryAdapter.swift
    M Source/WebKit/UIProcess/API/Swift/WKUIDelegateAdapter.swift
    M Source/WebKit/UIProcess/API/Swift/WebPage.swift
    M Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm
    M Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj
    M Source/WebKit/_WebKit_SwiftUI/CocoaWebViewAdapter.swift
    M Source/WebKit/_WebKit_SwiftUI/Foundation+Extras.swift
    A Source/WebKit/_WebKit_SwiftUI/SwiftUI+Extras.swift
    M Source/WebKit/_WebKit_SwiftUI/View+WebViewModifiers.swift
    A Source/WebKit/_WebKit_SwiftUI/ViewModifierContexts.swift
    M Source/WebKit/_WebKit_SwiftUI/WebViewRepresentable.swift

  Log Message:
  -----------
  [SwiftUI] Provide ability for clients to tell when WebView scroll geometry has changed
https://bugs.webkit.org/show_bug.cgi?id=288242
rdar://145321354

Reviewed by Aditya Keerthi.

Add a new `webViewOnScrollGeometryChange` view modifier to `WebView` to provide clients the ability
to respond to changes to various sizes and geometries that are modified by scrolling.

To facilitate this, layer tree transaction updates are propogated through a new `WKUIDelegateInternal`
protocol. The `WKUIDelegateAdapter` type now conforms to this new protocol, and passes the information
to `CocoaWebViewAdapter`, which then notifies the closures provided by the view modifier.

The `WKUIDelegateAdapter` type is made to more accurately reflect its conformance by conforming to `WKUIDelegatePrivate`.
However, this is still not _entirely_ accurate since it does also conform to `WKUIDelegateInternal`, however this
conformance cannot be statically stated since types imported via `internal import` can't appear in places that are outside
the project scope, which `WKUIDelegateAdapter` is.

* Source/WebKit/Modules/Internal/WebKitInternal.h:
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/API/APIUIClient.h:
(API::UIClient::geometryDidChange):
* Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKScrollGeometry.h: Copied from Source/WebKit/Modules/Internal/WebKitInternal.h.
* Source/WebKit/UIProcess/API/Cocoa/_WKScrollGeometry.mm: Copied from Source/WebKit/Modules/Internal/WebKitInternal.h.
(-[_WKScrollGeometry initWithContainerSize:contentInsets:contentOffset:contentSize:]):
* Source/WebKit/UIProcess/API/Swift/WKScrollGeometryAdapter.swift: Copied from Source/WebKit/_WebKit_SwiftUI/Foundation+Extras.swift.
* Source/WebKit/UIProcess/API/Swift/WKUIDelegateAdapter.swift:
(WKUIDelegateAdapter._webView(_:geometryDidChange:)):
* Source/WebKit/UIProcess/API/Swift/WebPage.swift:
(WebPageWebView.geometryDidChange(_:)):
(Delegate.geometryDidChange(_:)):
* Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm:
(WebKit::PageClientImplCocoa::didCommitLayerTree):
* Source/WebKit/UIProcess/Cocoa/UIDelegate.h:
* Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::setDelegate):
(WebKit::UIDelegate::UIClient::geometryDidChange):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::commitLayerTreeTransaction):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/_WebKit_SwiftUI/CocoaWebViewAdapter.swift:
(CocoaWebViewAdapter.onScrollGeometryChange):
(CocoaWebViewAdapter.currentScrollGeometry):
(CocoaWebViewAdapter.contentView):
(CocoaWebViewAdapter.findBarViewDidChangeHeight):
(CocoaWebViewAdapter.geometryDidChange(_:)):
* Source/WebKit/_WebKit_SwiftUI/Foundation+Extras.swift:
* Source/WebKit/_WebKit_SwiftUI/SwiftUI+Extras.swift: Added.
* Source/WebKit/_WebKit_SwiftUI/View+WebViewModifiers.swift:
(EnvironmentValues.webViewOnScrollGeometryChange):
(View.webViewContentBackground(_:)):
(FindContext.isPresented): Deleted.
* Source/WebKit/_WebKit_SwiftUI/ViewModifierContexts.swift: Copied from Source/WebKit/_WebKit_SwiftUI/Foundation+Extras.swift.
(FindContext.isPresented):
* Source/WebKit/_WebKit_SwiftUI/WebViewRepresentable.swift:
(WebViewRepresentable.updatePlatformView(_:context:)):

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



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list