[webkit-changes] [WebKit/WebKit] 00b120: [iOS] Stop conforming to private UIKit ObjC protoc...

Wenson Hsieh noreply at github.com
Tue Oct 31 14:21:48 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 00b1201b3e8991387c6b3c15a660c3a29e71d7a6
      https://github.com/WebKit/WebKit/commit/00b1201b3e8991387c6b3c15a660c3a29e71d7a6
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-10-31 (Tue, 31 Oct 2023)

  Changed paths:
    M Source/WTF/wtf/PlatformHave.h
    M Source/WebCore/platform/ios/WebEvent.mm
    M Source/WebCore/platform/ios/WebEventPrivate.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h
    M Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm
    M Source/WebKit/UIProcess/ios/WKContentView.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/TestRunnerShared/spi/UIKitSPIForTesting.h
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm
    M Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  [iOS] Stop conforming to private UIKit ObjC protocols when "Async UIKit Interactions" is enabled
https://bugs.webkit.org/show_bug.cgi?id=263813
rdar://117611037

Reviewed by Aditya Keerthi.

Refactor UIKit async interaction support:

•   Rename `HAVE(UI_ASYNC_TEXT_INPUT)` to `HAVE(UI_ASYNC_TEXT_INTERACTION)`, and guard compile-time
    enablement on the availability of `UIAsyncTextInteraction.h`. This allows us to remain source-
    compatible with versions of UIKit that have slightly-older versions of `UIAsyncTextInput.h`,
    that are missing a declaration of `UITextReplacementOptions`.

•   Stop declaring conformance at compile-time to the following 5 SPI protocols, from UIKit:
      • `UIWKInteractionViewProtocol`
      • `UITextInputPrivate`
      • `UITextAutoscrolling`
      • `UITextInputMultiDocument`
      • `UITextInputTranslationSupport`
    ...and instead, conform to these protocols only when the `UseAsyncUIKitInteractions` internal
    preference is disabled.

•   Make this logic run once, immediately upon content view initialization, to limit any risk that
    any logic that depends on the content view conforming to any of these protocols might be broken
    after this refactoring.

This will put us in a position where we can easily test against versions of UIKit that have system
support for `UIAsyncTextInput`, while revealing any interactions or features that might still be
relying on the 5 protocols listed above. It also puts us in a better position to completely remove
reliance on those protocols once the `UseAsyncUIKitInteractions` preference is enabled by default,
simply by removing the logic to establish conformance at runtime.

* Source/WTF/wtf/PlatformHave.h:
* Source/WebCore/platform/ios/WebEvent.mm:
* Source/WebCore/platform/ios/WebEventPrivate.h:
* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm:
(-[WKWebView _requestDocumentContext:completionHandler:]): Deleted.
(-[WKWebView _adjustSelectionWithDelta:completionHandler:]): Deleted.
(-[WKWebView applyAutocorrection:toString:withCompletionHandler:]): Deleted.
(-[WKWebView applyAutocorrection:toString:isCandidate:withCompletionHandler:]): Deleted.
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _commonInitializationWithProcessPool:configuration:]):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateRuntimeProtocolConformanceIfNeeded]):
(-[WKContentView setUpInteraction]):
(-[WKContentView _interpretKeyEvent:isCharEvent:]):
(-[WKContentView _ensureBinaryCompatibilityWithAsyncInteractionsIfNeeded]): Deleted.

Rename this to `-_updateRuntimeProtocolConformanceIfNeeded`, to better reflect its new role, now
that it adds protocol conformance to several legacy UIKit protocols at runtime.

* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::dispatchWheelEventWithoutScrolling):
* Tools/TestRunnerShared/spi/UIKitSPIForTesting.h:

Move the protocol declarations out of `UIKitSPI.h`, and into `UIKitSPIForTesting.h`.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
(-[TestWKWebView synchronouslyRequestDocumentContext:]):
(-[TestWKWebView synchronouslyAdjustSelectionWithDelta:]):
* Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::applyAutocorrection):

Adjust some test infrastructure to stop using the deleted testing hooks, and instead just call into
`WKContentView` directly, like most of the other API tests already do.

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




More information about the webkit-changes mailing list