Bug 196021

Summary: [iOS] Inline -_ensureFormAccessoryView into -formAccessoryView and have -_updateAccessory ensure we have a form accessory
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebKit Misc.Assignee: Daniel Bates <dbates>
Status: RESOLVED FIXED    
Severity: Normal CC: thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: iOS 12   
Attachments:
Description Flags
Patch
none
To Land none

Description Daniel Bates 2019-03-20 11:49:48 PDT
I don't see much benefit to -formAccessoryView being implemented in terms of -_ensureFormAccessoryView just inline the latter into the former and remove a method. Also, every caller except -formAccessoryView calls -_ensureFormAccessoryView followed immediately by -_updateAccessory. So, let's have -_updateAccessory just ensure we have a form accessory view instead of each caller.
Comment 1 Daniel Bates 2019-03-20 11:55:14 PDT
Created attachment 365374 [details]
Patch
Comment 2 Wenson Hsieh 2019-03-21 10:47:16 PDT
Comment on attachment 365374 [details]
Patch

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

> Source/WebKit/ChangeLog:9
> +        Every caller of -_ensureFormAccessoryView, except -formAccessoryView, immediately the call with
> +        -_updateAccessory. Let's just have -_updateAccessory ensure we have a form accessory view and

Nit - "immediately the call with"

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:3784
> +    [self formAccessoryView]; // Creates one if needed.

Nit - we can also do something like:

    UIWebFormAccessory *accessoryView = [self formAccessoryView];

...and then just use the accessoryView variable below, instead of _formAccessoryView. I think we wouldn't need the comment if we did this.
Comment 3 Daniel Bates 2019-03-21 11:01:57 PDT
Comment on attachment 365374 [details]
Patch

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

>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:3784
>> +    [self formAccessoryView]; // Creates one if needed.
> 
> Nit - we can also do something like:
> 
>     UIWebFormAccessory *accessoryView = [self formAccessoryView];
> 
> ...and then just use the accessoryView variable below, instead of _formAccessoryView. I think we wouldn't need the comment if we did this.

Of course! What was I thinking!
Comment 4 Daniel Bates 2019-03-21 11:10:07 PDT
Comment on attachment 365374 [details]
Patch

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

>>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:3784
>>> +    [self formAccessoryView]; // Creates one if needed.
>> 
>> Nit - we can also do something like:
>> 
>>     UIWebFormAccessory *accessoryView = [self formAccessoryView];
>> 
>> ...and then just use the accessoryView variable below, instead of _formAccessoryView. I think we wouldn't need the comment if we did this.
> 
> Of course! What was I thinking!

I'm still going to keep the comment though, because it seems subtle and I absolutely can envision a person in the future coming through this code,  realizing we have _formAccessoryView and without thinking swap out the self.formAccessoryView with _formAccessoryView.
Comment 5 Daniel Bates 2019-03-21 11:10:58 PDT
(In reply to Daniel Bates from comment #4)
> Comment on attachment 365374 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=365374&action=review
> 
> >>> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:3784
> >>> +    [self formAccessoryView]; // Creates one if needed.
> >> 
> >> Nit - we can also do something like:
> >> 
> >>     UIWebFormAccessory *accessoryView = [self formAccessoryView];
> >> 
> >> ...and then just use the accessoryView variable below, instead of _formAccessoryView. I think we wouldn't need the comment if we did this.
> > 
> > Of course! What was I thinking!
> 
> I'm still going to keep the comment though, because it seems subtle and I
> absolutely can envision a person in the future coming through this code, 
> realizing we have _formAccessoryView and without thinking swap out the
> self.formAccessoryView with _formAccessoryView.

Having a test would be better to catch this though :/ Leaving the comment in for now.
Comment 6 Daniel Bates 2019-03-21 11:14:01 PDT
Created attachment 365573 [details]
To Land
Comment 7 Daniel Bates 2019-03-21 11:15:04 PDT
Committed r243302: <https://trac.webkit.org/changeset/243302>
Comment 8 Radar WebKit Bug Importer 2019-03-21 11:16:17 PDT
<rdar://problem/49115052>