Skip to content

Commit

Permalink
[UIAsyncTextInput] [WebKit] Adopt API replacements for UITextSuggesti…
Browse files Browse the repository at this point in the history
…onDelegate

https://bugs.webkit.org/show_bug.cgi?id=265097
rdar://118589483

Reviewed by Megan Gardner.

Replace calls to `-[UITextInputSuggestionDelegate setSuggestions:]` with
`-[UIAsyncTextInputDelegate provideCandidateUISuggestions:]`, which provides equivalent
functionality. No change in behavior.

* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKFormInputSession invalidate]):
(-[WKContentView updateTextSuggestionsForInputDelegate]):
(-[WKContentView _provideSuggestionsToInputDelegate:]):

Canonical link: https://commits.webkit.org/271120@main
  • Loading branch information
whsieh committed Nov 26, 2023
1 parent 8c078c7 commit 1a9127d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions Source/WebKit/Platform/spi/ios/UIKitSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -1264,6 +1264,7 @@ typedef struct {
@protocol UIAsyncTextInputDelegate_Staging<UIAsyncTextInputDelegate>
- (void)invalidateTextEntryContext; // Added in rdar://118536368.
- (void)replaceText:(id)sender; // Added in rdar://118307558.
- (void)provideCandidateUISuggestions:(NSArray<UITextSuggestion*> *)suggestions; // Added in rdar://117914235.
@end

#endif // HAVE(UI_ASYNC_TEXT_INTERACTION)
Expand Down
1 change: 1 addition & 0 deletions Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
- (void)_didNotHandleTapAsClick:(const WebCore::IntPoint&)point;
- (void)_didHandleTapAsHover;
- (void)_didCompleteSyntheticClick;
- (void)_provideSuggestionsToInputDelegate:(NSArray<UITextSuggestion *> *)suggestions;

- (void)_didGetTapHighlightForRequest:(WebKit::TapIdentifier)requestID color:(const WebCore::Color&)color quads:(const Vector<WebCore::FloatQuad>&)highlightedQuads topLeftRadius:(const WebCore::IntSize&)topLeftRadius topRightRadius:(const WebCore::IntSize&)topRightRadius bottomLeftRadius:(const WebCore::IntSize&)bottomLeftRadius bottomRightRadius:(const WebCore::IntSize&)bottomRightRadius nodeHasBuiltInClickHandling:(BOOL)nodeHasBuiltInClickHandling;

Expand Down
21 changes: 14 additions & 7 deletions Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,7 @@ - (BOOL)requiresStrongPasswordAssistance

- (void)invalidate
{
id <UITextInputSuggestionDelegate> suggestionDelegate = (id <UITextInputSuggestionDelegate>)[_contentView inputDelegate];
[suggestionDelegate setSuggestions:nil];
_contentView = nil;
[std::exchange(_contentView, nil) _provideSuggestionsToInputDelegate:nil];
}

- (void)reloadFocusedElementContextView
Expand Down Expand Up @@ -8750,21 +8748,30 @@ - (void)setDataListTextSuggestions:(NSArray<UITextSuggestion *> *)textSuggestion
- (void)updateTextSuggestionsForInputDelegate
{
// Text suggestions vended from clients take precedence over text suggestions from a focused form control with a datalist.
id <UITextInputSuggestionDelegate> inputDelegate = (id <UITextInputSuggestionDelegate>)self.inputDelegate;
NSArray<UITextSuggestion *> *formInputSessionSuggestions = [_formInputSession suggestions];
if (formInputSessionSuggestions.count) {
[inputDelegate setSuggestions:formInputSessionSuggestions];
[self _provideSuggestionsToInputDelegate:formInputSessionSuggestions];
return;
}

#if ENABLE(DATALIST_ELEMENT)
if ([_dataListTextSuggestions count]) {
[inputDelegate setSuggestions:_dataListTextSuggestions.get()];
[self _provideSuggestionsToInputDelegate:_dataListTextSuggestions.get()];
return;
}
#endif

[inputDelegate setSuggestions:nil];
[self _provideSuggestionsToInputDelegate:nil];
}

- (void)_provideSuggestionsToInputDelegate:(NSArray<UITextSuggestion *> *)suggestions
{
#if HAVE(UI_ASYNC_TEXT_INTERACTION)
if (self.shouldUseAsyncInteractions)
[_asyncSystemInputDelegate provideCandidateUISuggestions:suggestions];
else
#endif
[(id<UITextInputSuggestionDelegate>)self.inputDelegate setSuggestions:suggestions];
}

- (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const WebCore::IntRect&)elementRect routeSharingPolicy:(WebCore::RouteSharingPolicy)routeSharingPolicy routingContextUID:(NSString *)routingContextUID
Expand Down

0 comments on commit 1a9127d

Please sign in to comment.