[webkit-changes] [WebKit/WebKit] e6a7b7: Adopt the ServiceExtensions framework for async te...
Wenson Hsieh
noreply at github.com
Wed Dec 13 20:02:09 PST 2023
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e6a7b742d24d37554294e235e5026cd9b86abc04
https://github.com/WebKit/WebKit/commit/e6a7b742d24d37554294e235e5026cd9b86abc04
Author: Wenson Hsieh <wenson_hsieh at apple.com>
Date: 2023-12-13 (Wed, 13 Dec 2023)
Changed paths:
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/platform/ios/WebEvent.mm
M Source/WebCore/platform/ios/WebEventPrivate.h
A Source/WebCore/platform/ios/WebSEDefinitions.h
M Source/WebKit/Platform/spi/ios/UIKitSPI.h
M Source/WebKit/Shared/DocumentEditingContext.h
M Source/WebKit/Shared/DocumentEditingContext.mm
M Source/WebKit/UIProcess/API/ios/WKSEDefinitions.h
M Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h
M Source/WebKit/UIProcess/WebPageProxy.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
M Source/WebKit/UIProcess/ios/WKExtendedTextInputTraits.h
M Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.h
M Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm
M Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.h
M Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm
M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
M Source/WebKit/WebProcess/WebPage/WebPage.h
M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
Log Message:
-----------
Adopt the ServiceExtensions framework for async text input support
https://bugs.webkit.org/show_bug.cgi?id=266302
rdar://119568570
Reviewed by Tim Horton.
Adopt `WKSE*`-prefixed objects, which are aliased to the new classes, protocols, or types and
constants exposed from the ServiceExtensions framework (if available), or otherwise aliased to the
`UIAsync*` SPI names.
No change in behavior; see below for more details.
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/platform/ios/WebEvent.mm:
(webEventType):
(isChangingKeyModifiers):
(-[WebEvent initWithKeyEvent:]):
(-[WebEvent originalKeyEvent]):
(-[WebEvent initWithUIKeyEvent:]): Deleted.
(-[WebEvent originalUIKeyEvent]): Deleted.
* Source/WebCore/platform/ios/WebEventPrivate.h:
* Source/WebCore/platform/ios/WebSEDefinitions.h: Copied from Source/WebKit/UIProcess/API/ios/WKSEDefinitions.h.
* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/Shared/DocumentEditingContext.h:
* Source/WebKit/Shared/DocumentEditingContext.mm:
(WebKit::setOptionalEditingContextProperties):
(WebKit::DocumentEditingContext::toLegacyPlatformContext):
(WebKit::DocumentEditingContext::toPlatformContext):
* Source/WebKit/UIProcess/API/ios/WKSEDefinitions.h:
* Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateRuntimeProtocolConformanceIfNeeded]):
(-[WKContentView textInteractionGesture:shouldBeginAtPoint:]):
(toGestureType):
(toWKSEGestureType):
(toSelectionTouch):
(toWKSESelectionTouch):
(toWKSESelectionFlags):
(toSelectionFlags):
(selectionChangedWithGesture):
(selectionChangedWithTouch):
(-[WKContentView changeSelectionWithGestureAt:withGesture:withState:]):
(-[WKContentView changeSelectionWithGestureAt:withGesture:withState:withFlags:]):
(-[WKContentView changeSelectionWithTouchAt:withSelectionTouch:baseIsStart:withFlags:]):
(-[WKContentView changeSelectionWithTouchesFrom:to:withGesture:withState:]):
(logTextInteraction):
(-[WKContentView insertTextSuggestion:]):
(shiftKeyState):
(-[WKContentView _deferKeyEventToInputMethodEditing:]):
(-[WKContentView _interpretKeyEvent:isCharEvent:]):
(-[WKContentView dataListTextSuggestions]):
(-[WKContentView setDataListTextSuggestions:]):
(-[WKContentView updateTextSuggestionsForInputDelegate]):
(-[WKContentView _provideSuggestionsToInputDelegate:]):
(-[WKContentView _provideUITextSuggestionsToInputDelegate:]):
(toWebRequest):
(-[WKContentView requestDocumentContext:completionHandler:]):
Make the completion handler here take an `NSObject`, representing either a `UIWKDocumentRequest` or
the replacement class from ServiceExtensions. This allows us to maintain both binary and source
compatibility in all the following cases:
- Against iOS 17, which doesn't have async text input support at all, or against versions of iOS
17 that have `UIAsyncTextInput` but not the replacement APIs in ServiceExtensions. We fall back
to `UIWKDocumentContext` here.
- Building/running against versions of iOS 17 that have both `UIAsyncTextInput` and the requisite
APIs in ServiceExtensions, but have `UIKit/async_text_input` disabled by default — here, we use
the new ServiceExtensions API objects and flags (which, for the most part, maintain binary
compatibility), with the exception of `WKSETextDocumentRequest`. In the completion handler, if
async text input is disabled, we return a `UIWKDocumentRequest` to maintain binary
compatibility.
- Lastly, building/running against versions of iOS 17 that have both `UIAsyncTextInput` and the
requisite APIs in ServiceExtensions, and enable `UIKit/async_text_input` by default. Here, we
return the new `WKSETextDocumentRequest`.
(-[WKContentView selectPositionAtPoint:withContextRequest:completionHandler:]):
(-[WKContentView asyncSystemInputDelegate]):
(-[WKContentView setAsyncSystemInputDelegate:]):
(-[WKContentView handleAsyncKeyEvent:withCompletionHandler:]):
(-[WKContentView replaceText:withText:options:withCompletionHandler:]):
(-[WKContentView requestTextContextForAutocorrectionWithCompletionHandler:]):
Refactor this code to use `WebKit::DocumentEditingContext` to create the document context, to avoid
having to duplicate messy logic for initializing either of the two `WKSETextDocumentRequest` types,
depending on the SDK version. Note: we don't need to consult the async text input feature flag here
and return a legacy `UIWKDocumentRequest`, since this codepath is only ever invoked in the async
text input codepath to begin with.
(-[WKContentView adjustSelection:completionHandler:]):
(-[WKContentView shiftKeyStateChangedFrom:to:]):
(-[WKContentView selectionWillChange:]):
(-[WKContentView selectionDidChange:]):
(toUIWKGestureType): Deleted.
(toUIWKSelectionTouch): Deleted.
(toUIWKSelectionFlags): Deleted.
* Source/WebKit/UIProcess/ios/WKExtendedTextInputTraits.h:
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.h:
* Source/WebKit/UIProcess/ios/WKTextInteractionWrapper.mm:
(-[WKTextInteractionWrapper initWithView:]):
(-[WKTextInteractionWrapper selectionChangedWithGestureAt:withGesture:withState:withFlags:]):
(-[WKTextInteractionWrapper selectionChangedWithTouchAt:withSelectionTouch:withFlags:]):
(SOFT_LINK_CLASS_OPTIONAL): Deleted.
* Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.h:
* Source/WebKit/UIProcess/ios/WebDataListSuggestionsDropdownIOS.mm:
(+[WKDataListTextSuggestion textSuggestionWithInputText:]):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::requestDocumentEditingContext):
Drive-by fixes: make both the completion handler and method itself take rvalue references, instead
of passing by value.
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::requestDocumentEditingContext):
Canonical link: https://commits.webkit.org/272018@main
More information about the webkit-changes
mailing list