Bug 210194 - [iOS] Date and time form controls are presented at the wrong size in some modes
Summary: [iOS] Date and time form controls are presented at the wrong size in some modes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Megan Gardner
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-08 09:59 PDT by Megan Gardner
Modified: 2020-04-09 10:55 PDT (History)
2 users (show)

See Also:


Attachments
Patch (4.29 KB, patch)
2020-04-08 10:04 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.01 KB, patch)
2020-04-08 10:26 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.04 KB, patch)
2020-04-08 10:27 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff
Patch (4.43 KB, patch)
2020-04-08 11:55 PDT, Megan Gardner
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Megan Gardner 2020-04-08 09:59:07 PDT
Update Sizes calculations for Date/Time form controls
Comment 1 Megan Gardner 2020-04-08 10:04:03 PDT
Created attachment 395825 [details]
Patch
Comment 2 Megan Gardner 2020-04-08 10:26:23 PDT
Created attachment 395830 [details]
Patch
Comment 3 Megan Gardner 2020-04-08 10:27:22 PDT
<rdar://problem/60385475>
Comment 4 Megan Gardner 2020-04-08 10:27:54 PDT
Created attachment 395831 [details]
Patch
Comment 5 Wenson Hsieh 2020-04-08 10:32:30 PDT
Comment on attachment 395831 [details]
Patch

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

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:120
> +    _datePicker = adoptNS([[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]);

Nit - this can just be adoptNS([[UIDatePicker alloc] init]);
Comment 6 Tim Horton 2020-04-08 10:35:10 PDT
Comment on attachment 395831 [details]
Patch

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

> Source/WebKit/ChangeLog:3
> +        Update Sizes calculations for Date/Time form controls

This is not a great title because it doesn't describe the problem. The radar title is ... better, but not great. Something more descriptive of the problem (like "[iOS] Date and time form controls are presented at the wrong size in some modes")  would be A++.

> Source/WebKit/ChangeLog:10
> +        Better calculations for sizes happen when we set the mode before calling
> +        sizeToFit.

This is not a great description.

I think the key is "defaultSizeForInterfaceOrientation is insufficient, we should let the UIDatePicker determine its own size given the configuration we're going to use" (but in different words)

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:120
> +    _datePicker = adoptNS([[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]);

CGRectZero is fine

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:130
> +    [_datePicker setFrame:CGRectMake(0, 0, size.width, size.height)];

isn't setFrameSize a thing? Or is that only on NSView?

> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:346
> +    [_viewController setPreferredContentSize:datePicker.frame.size];

Is this OK for all modes?
Comment 7 Tim Horton 2020-04-08 10:35:36 PDT
(In reply to Tim Horton from comment #6)
> Comment on attachment 395831 [details]
> Patch
> 
> > Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:120
> > +    _datePicker = adoptNS([[UIDatePicker alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]);
> 
> CGRectZero is fine

Though wenson is also right.
Comment 8 Wenson Hsieh 2020-04-08 10:46:44 PDT
Comment on attachment 395831 [details]
Patch

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

>> Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm:130
>> +    [_datePicker setFrame:CGRectMake(0, 0, size.width, size.height)];
> 
> isn't setFrameSize a thing? Or is that only on NSView?

AFAIK, this only exists as deprecated SPI on UIView (-setSize:).
Comment 9 Megan Gardner 2020-04-08 11:55:06 PDT
Created attachment 395849 [details]
Patch
Comment 10 EWS 2020-04-09 10:54:59 PDT
Committed r259806: <https://trac.webkit.org/changeset/259806>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 395849 [details].