Bug 183154 - Make it possible to set suggestions in extra zoom mode.
Summary: Make it possible to set suggestions in extra zoom mode.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yongjun Zhang
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-02-26 16:39 PST by Yongjun Zhang
Modified: 2018-02-27 12:14 PST (History)
5 users (show)

See Also:


Attachments
Patch. (6.52 KB, patch)
2018-02-26 16:53 PST, Yongjun Zhang
thorton: review+
Details | Formatted Diff | Diff
Addressing review comments. (6.47 KB, patch)
2018-02-27 11:38 PST, Yongjun Zhang
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yongjun Zhang 2018-02-26 16:39:12 PST
In extra zoom mode, a WebKit client should be able to set suggestions to the input view controller.
Comment 1 Yongjun Zhang 2018-02-26 16:40:34 PST
rdar://problem/35227450
Comment 2 Yongjun Zhang 2018-02-26 16:53:59 PST
Created attachment 334660 [details]
Patch.
Comment 3 Wenson Hsieh 2018-02-26 17:08:07 PST
Comment on attachment 334660 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=334660&action=review

> Source/WebKit/ChangeLog:11
> +        suggestions is updated. Later, when we present WKTextInputViewController, we can pass the cached

Nit - s/is/are/

> Source/WebKit/ChangeLog:15
> +        (-[WKContentView presentFocusedFormControlViewController:]): Set _viewControllerForFullScreenPresentationFromView as

Nit - I think you meant "Set _focusedFormControlViewController as the inputDelegate"?

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4211
> +    [self setInputDelegate:_focusedFormControlViewController.get()];

On second thought, it's a bit weird for the focused form control VC to be a UITextInput (I thought this was limited to the WKTextInputViewController). The focused form control overlay doesn't really deal with text input, but rather, with moving between focusable form controls on a page. Can we make WKTextInputVC the UITextInput, and just -setDelegate when presenting/dismissing the text input VC?

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4389
> +        [_textInputViewController setSuggestions:controller.suggestions];

Nit - We don't need this if statement here, since it'll just be a noop if _textInputViewController is nil.
Comment 4 Yongjun Zhang 2018-02-26 19:33:02 PST
Comment on attachment 334660 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=334660&action=review

>> Source/WebKit/ChangeLog:15
>> +        (-[WKContentView presentFocusedFormControlViewController:]): Set _viewControllerForFullScreenPresentationFromView as
> 
> Nit - I think you meant "Set _focusedFormControlViewController as the inputDelegate"?

Oh right.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4211
>> +    [self setInputDelegate:_focusedFormControlViewController.get()];
> 
> On second thought, it's a bit weird for the focused form control VC to be a UITextInput (I thought this was limited to the WKTextInputViewController). The focused form control overlay doesn't really deal with text input, but rather, with moving between focusable form controls on a page. Can we make WKTextInputVC the UITextInput, and just -setDelegate when presenting/dismissing the text input VC?

That was my first attempt, but it only works when the text input VC is brought up by [WKContentView _startAssistingNode:] (i.e., when tapping a text input element without the focused form control VC showing). If the focus form control VC is showing, and we tapping the input box, the text input VC will be brought up by [WKContentView focusedFormControlControllerDidBeginEditing:], which is too late to pick up the suggestions. I think the reason this happens is before moving between focusable text inputs, we dismiss the text input VC and nil it, then we move the focus to the next input and update the suggestions from _startAssistingNode:, but the input VC is now nil. That is why we need to somehow cache the suggestions while text input VC is nil and apply that when it is presented.

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4389
>> +        [_textInputViewController setSuggestions:controller.suggestions];
> 
> Nit - We don't need this if statement here, since it'll just be a noop if _textInputViewController is nil.

Ok, will fix.
Comment 5 Wenson Hsieh 2018-02-26 19:41:05 PST
Comment on attachment 334660 [details]
Patch.

View in context: https://bugs.webkit.org/attachment.cgi?id=334660&action=review

>>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:4211
>>> +    [self setInputDelegate:_focusedFormControlViewController.get()];
>> 
>> On second thought, it's a bit weird for the focused form control VC to be a UITextInput (I thought this was limited to the WKTextInputViewController). The focused form control overlay doesn't really deal with text input, but rather, with moving between focusable form controls on a page. Can we make WKTextInputVC the UITextInput, and just -setDelegate when presenting/dismissing the text input VC?
> 
> That was my first attempt, but it only works when the text input VC is brought up by [WKContentView _startAssistingNode:] (i.e., when tapping a text input element without the focused form control VC showing). If the focus form control VC is showing, and we tapping the input box, the text input VC will be brought up by [WKContentView focusedFormControlControllerDidBeginEditing:], which is too late to pick up the suggestions. I think the reason this happens is before moving between focusable text inputs, we dismiss the text input VC and nil it, then we move the focus to the next input and update the suggestions from _startAssistingNode:, but the input VC is now nil. That is why we need to somehow cache the suggestions while text input VC is nil and apply that when it is presented.

I see! This makes a bit more sense now. It still feels a bit weird that the text suggestions need to be stored in two places (the focused form VC as well as the text input VC). I would still prefer just storing it on the focused form VC and then adding a delegate method to WKTextFormControlViewControllerDelegate so that the WKTextInputVC (a subclass of WKTextFormControlVC) can ask the content view for text suggestions, and the content view would then get text suggestions off of the focused form control VC.

This is probably fine for now, though. Also, WKTextInputVC is just a stop-gap solution, and we'll need to rewrite parts of this soon anyways, so we can always refactor this later.

r=me, but this will also require a WK2 owner.
Comment 6 Yongjun Zhang 2018-02-27 11:38:46 PST
Created attachment 334695 [details]
Addressing review comments.
Comment 7 WebKit Commit Bot 2018-02-27 12:14:06 PST
Comment on attachment 334695 [details]
Addressing review comments.

Clearing flags on attachment: 334695

Committed r229067: <https://trac.webkit.org/changeset/229067>
Comment 8 WebKit Commit Bot 2018-02-27 12:14:07 PST
All reviewed patches have been landed.  Closing bug.