[webkit-changes] [WebKit/WebKit] 429bb1: Adopt _UIContextMenuAsyncConfiguration to let cont...

Wenson Hsieh noreply at github.com
Mon Oct 16 19:05:32 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 429bb1ad0f79cf369c4c81f7137636f4cfd8eee3
      https://github.com/WebKit/WebKit/commit/429bb1ad0f79cf369c4c81f7137636f4cfd8eee3
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-10-16 (Mon, 16 Oct 2023)

  Changed paths:
    M Source/WTF/wtf/PlatformHave.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

  Log Message:
  -----------
  Adopt _UIContextMenuAsyncConfiguration to let context menu interactions begin asynchronously
https://bugs.webkit.org/show_bug.cgi?id=263172
rdar://114349359

Reviewed by Tim Horton and Abrar Rahman Protyasha.

Adopt `_UIContextMenuAsyncConfiguration` in WebKit to support async context menu interactions
without the need to use the following private context menu delegate method:

```
- (void)_contextMenuInteraction:(UIContextMenuInteraction *)interaction
    configurationForMenuAtLocation:(CGPoint)location
    completion:(void(^)(UIContextMenuConfiguration *))completion;
```

To use the new context menu async configuration, we simply return `_UIContextMenuAsyncConfiguration`
synchronously from the normal API context menu configuration delegate method; later, when we have
the concrete context menu configuration that we should proceed with, we call
`-fulfillWithConfiguration:` to swap out the placeholder async configuration with the real
configuration, which allows UIKit to proceed with the interaction.

* Source/WTF/wtf/PlatformHave.h:

Add new compile-time feature flags.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:

Drive-by fix: put conformance to `UIAsyncTextInput` behind a runtime flag as well, to make staged
API adoption possible.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:

Add soft-link support for some of the new classes, to help preserve binary compatibility.

(-[WKContentView _shouldUseUIContextMenuAsyncConfiguration]):

Return `YES` if and only if we're building for an OS with `_UIContextMenuAsyncConfiguration`, and
`_UIContextMenuAsyncConfiguration` also exists in the runtime.

(-[WKContentView _ensureBinaryCompatibilityWithAsyncInteractionsIfNeeded]):

In order to properly opt into the `_UIContextMenuAsyncConfiguration` codepath, we can't implement
the legacy async method (`-_contextMenuInteraction:configurationForMenuAtLocation:completion:`),
since that legacy method takes priority (because UIKit only calls one of either the legacy async
method or the normal context menu configuration API delegate method).

However, since we still need to continue supporting the legacy async codepath when the runtime
feature flag is off, we need to implement the legacy async delegate method if the feature flag is
disabled (or `_UIContextMenuAsyncConfiguration` is otherwise unavailable).

To make this all work, we rename the existing async delegate method to have an `_internal` prefix,
and then use `class_addMethod` to dynamically add an implementation of the legacy async codepath if
needed.

(-[WKContentView setUpInteraction]):
(-[WKContentView _dragInteractionClass]):

Drive-by fix: soft link `_UIAsyncDragInteraction` so that we don't crash on launch, when testing
against builds without UIKit support for `_UIAsyncDragInteraction`.

(-[WKContentView contextMenuInteraction:configurationForMenuAtLocation:]):
(-[WKContentView _internalContextMenuInteraction:configurationForMenuAtLocation:completion:]):
(-[WKContentView _contextMenuInteraction:configurationForMenuAtLocation:completion:]): Deleted.

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




More information about the webkit-changes mailing list