Changeset 228393 in webkit


Ignore:
Timestamp:
Feb 12, 2018 2:07:10 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[Extra zoom mode] Add support for <input type='time'> using time picker UI
https://bugs.webkit.org/show_bug.cgi?id=182683
<rdar://problem/35143162>

Reviewed by Tim Horton.

Adds support for showing a time picker when an input of type time is focused in extra zoomed mode.

  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _stopAssistingNode]):
(-[WKContentView presentTimePickerViewController:]):
(-[WKContentView dismissTimePickerViewController:]):

Add helpers to dismiss and present the time picker view controller.

(-[WKContentView presentViewControllerForAssistedNode:]):

When focusing InputType::Time, present a time picker. Additionally, tweak the logic here to use the generic text
input view controller as a fallback when the other input view controllers (number pads, select menus and time
pickers thus far) are not relevant. This prevents us from completely being unable to edit form controls that are
currently unsupported.

(-[WKContentView textInputController:didCommitText:]):
(-[WKContentView textInputControllerDidRequestDismissal:]):

Tweak WKContentView for changes to WKTextFormControlViewControllerDelegate.

(-[WKContentView actionNameForFocusedFormControlController:]):

Adjust this implementation to hide the focused form control "Go" button for selects and time inputs. This
currently doesn't work for these form controls because it relies on implicit form submission; this should be
fixed by future changes, after which we should revert this adjustment.

(-[WKContentView _wheelChangedWithEvent:]):

Delegate wheel events to the time picker if needed.

(-[WKContentView textInputController:didRequestDismissalWithAction:]): Deleted.

Renamed to -textInputControllerDidRequestDismissal:.

  • UIProcess/ios/forms/WKTimePickerViewController.h: Added.
  • UIProcess/ios/forms/WKTimePickerViewController.mm: Added.
  • WebKit.xcodeproj/project.pbxproj:
Location:
trunk/Source/WebKit
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r228373 r228393  
     12018-02-12  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [Extra zoom mode] Add support for <input type='time'> using time picker UI
     4        https://bugs.webkit.org/show_bug.cgi?id=182683
     5        <rdar://problem/35143162>
     6
     7        Reviewed by Tim Horton.
     8
     9        Adds support for showing a time picker when an input of type time is focused in extra zoomed mode.
     10
     11        * UIProcess/ios/WKContentViewInteraction.h:
     12        * UIProcess/ios/WKContentViewInteraction.mm:
     13        (-[WKContentView _stopAssistingNode]):
     14        (-[WKContentView presentTimePickerViewController:]):
     15        (-[WKContentView dismissTimePickerViewController:]):
     16
     17        Add helpers to dismiss and present the time picker view controller.
     18
     19        (-[WKContentView presentViewControllerForAssistedNode:]):
     20
     21        When focusing InputType::Time, present a time picker. Additionally, tweak the logic here to use the generic text
     22        input view controller as a fallback when the other input view controllers (number pads, select menus and time
     23        pickers thus far) are not relevant. This prevents us from completely being unable to edit form controls that are
     24        currently unsupported.
     25
     26        (-[WKContentView textInputController:didCommitText:]):
     27        (-[WKContentView textInputControllerDidRequestDismissal:]):
     28
     29        Tweak WKContentView for changes to WKTextFormControlViewControllerDelegate.
     30
     31        (-[WKContentView actionNameForFocusedFormControlController:]):
     32
     33        Adjust this implementation to hide the focused form control "Go" button for selects and time inputs. This
     34        currently doesn't work for these form controls because it relies on implicit form submission; this should be
     35        fixed by future changes, after which we should revert this adjustment.
     36
     37        (-[WKContentView _wheelChangedWithEvent:]):
     38
     39        Delegate wheel events to the time picker if needed.
     40
     41        (-[WKContentView textInputController:didRequestDismissalWithAction:]): Deleted.
     42
     43        Renamed to -textInputControllerDidRequestDismissal:.
     44
     45        * UIProcess/ios/forms/WKTimePickerViewController.h: Added.
     46        * UIProcess/ios/forms/WKTimePickerViewController.mm: Added.
     47        * WebKit.xcodeproj/project.pbxproj:
     48
    1492018-02-11  Michael Catanzaro  <mcatanzaro@igalia.com>
    250
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r228245 r228393  
    8989@class WKSelectMenuViewController;
    9090@class WKTextInputViewController;
     91@class WKTimePickerViewController;
    9192#endif
    9293
     
    250251    RetainPtr<WKNumberPadViewController> _numberPadViewController;
    251252    RetainPtr<WKSelectMenuViewController> _selectMenuViewController;
     253    RetainPtr<WKTimePickerViewController> _timePickerViewController;
    252254#endif
    253255}
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r228246 r228393  
    5454#import "WKSelectMenuViewController.h"
    5555#import "WKTextInputViewController.h"
     56#import "WKTimePickerViewController.h"
    5657#import "WKUIDelegatePrivate.h"
    5758#import "WKWebViewConfiguration.h"
     
    40924093    [self dismissNumberPadViewController:YES];
    40934094    [self dismissSelectMenuViewController:YES];
     4095    [self dismissTimePickerViewController:YES];
    40944096    if (!_isChangingFocus)
    40954097        [self dismissFocusedFormControlViewController:[_focusedFormControlViewController isVisible]];
     
    41054107#if ENABLE(EXTRA_ZOOM_MODE)
    41064108
     4109- (void)presentTimePickerViewController:(BOOL)animated
     4110{
     4111    if (_timePickerViewController)
     4112        return;
     4113
     4114    _timePickerViewController = adoptNS([[WKTimePickerViewController alloc] initWithText:_assistedNodeInformation.value textSuggestions:@[ ]]);
     4115    [_timePickerViewController setDelegate:self];
     4116    [_focusedFormControlViewController presentViewController:_timePickerViewController.get() animated:animated completion:nil];
     4117}
     4118
     4119- (void)dismissTimePickerViewController:(BOOL)animated
     4120{
     4121    if (!_timePickerViewController)
     4122        return;
     4123
     4124    auto timePickerViewController = WTFMove(_timePickerViewController);
     4125    [timePickerViewController dismissViewControllerAnimated:animated completion:nil];
     4126}
     4127
    41074128- (void)presentSelectMenuViewController:(BOOL)animated
    41084129{
     
    41654186{
    41664187    switch (info.elementType) {
    4167     case InputType::ContentEditable:
    4168     case InputType::Text:
    4169     case InputType::Password:
    4170     case InputType::TextArea:
    4171     case InputType::Search:
    4172     case InputType::Email:
    4173     case InputType::URL:
    4174         [self presentTextInputViewController:YES];
    4175         break;
    41764188    case InputType::Number:
    41774189    case InputType::NumberPad:
     
    41824194        [self presentSelectMenuViewController:YES];
    41834195        break;
     4196    case InputType::Time:
     4197        [self presentTimePickerViewController:YES];
     4198        break;
     4199    case InputType::None:
     4200        break;
    41844201    default:
     4202        [self presentTextInputViewController:YES];
    41854203        break;
    41864204    }
     
    42104228    // FIXME: Update cached AssistedNodeInformation state in the UI process.
    42114229    _page->setTextAsync(text);
    4212 }
    4213 
    4214 - (void)textInputController:(WKTextFormControlViewController *)controller didRequestDismissalWithAction:(WKFormControlAction)action
    4215 {
    4216     if (action == WKFormControlActionCancel) {
    4217         _page->blurAssistedNode();
    4218         return;
    4219     }
    4220 
    4221     if (_assistedNodeInformation.formAction.isEmpty() && !_assistedNodeInformation.hasNextNode && !_assistedNodeInformation.hasPreviousNode) {
     4230
     4231    if (![self actionNameForFocusedFormControlController:_focusedFormControlViewController.get()] && !_assistedNodeInformation.hasNextNode && !_assistedNodeInformation.hasPreviousNode) {
    42224232        // In this case, there's no point in collapsing down to the form control focus UI because there's nothing the user could potentially do
    42234233        // besides dismiss the UI, so we just automatically dismiss the focused form control UI.
     
    42294239    [self dismissTextInputViewController:YES];
    42304240    [self dismissNumberPadViewController:YES];
     4241    [self dismissTimePickerViewController:YES];
     4242}
     4243
     4244- (void)textInputControllerDidRequestDismissal:(WKTextFormControlViewController *)controller
     4245{
     4246    _page->blurAssistedNode();
    42314247}
    42324248
     
    42574273        return nil;
    42584274
    4259     return _assistedNodeInformation.elementType == InputType::Search ? formControlSearchButtonTitle() : formControlGoButtonTitle();
     4275    switch (_assistedNodeInformation.elementType) {
     4276    case InputType::Select:
     4277    case InputType::Time:
     4278    case InputType::Date:
     4279        return nil;
     4280    case InputType::Search:
     4281        return formControlSearchButtonTitle();
     4282    default:
     4283        return formControlGoButtonTitle();
     4284    }
    42604285}
    42614286
     
    43704395
    43714396    if ([_selectMenuViewController handleWheelEvent:event])
     4397        return;
     4398
     4399    if ([_timePickerViewController handleWheelEvent:event])
    43724400        return;
    43734401
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r228287 r228393  
    741741                2EA7B3D52026CF23009CE5AC /* WKNumberPadView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA7B3D32026CF23009CE5AC /* WKNumberPadView.h */; };
    742742                2EA7B3D62026CF23009CE5AC /* WKNumberPadView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EA7B3D42026CF23009CE5AC /* WKNumberPadView.mm */; };
     743                2EB6FC01203021960017E619 /* WKTimePickerViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */; };
     744                2EB6FC02203021960017E619 /* WKTimePickerViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EB6FC00203021960017E619 /* WKTimePickerViewController.mm */; };
    743745                2EE4529F20292D2A00D81777 /* WKSelectMenuViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EE4529C20292BD900D81777 /* WKSelectMenuViewController.h */; };
    744746                2EE452A020292D2E00D81777 /* WKSelectMenuViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2EE4529B20292BD800D81777 /* WKSelectMenuViewController.mm */; };
     
    31013103                2EA7B3D32026CF23009CE5AC /* WKNumberPadView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKNumberPadView.h; path = ios/forms/WKNumberPadView.h; sourceTree = "<group>"; };
    31023104                2EA7B3D42026CF23009CE5AC /* WKNumberPadView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKNumberPadView.mm; path = ios/forms/WKNumberPadView.mm; sourceTree = "<group>"; };
     3105                2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKTimePickerViewController.h; path = ios/forms/WKTimePickerViewController.h; sourceTree = "<group>"; };
     3106                2EB6FC00203021960017E619 /* WKTimePickerViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKTimePickerViewController.mm; path = ios/forms/WKTimePickerViewController.mm; sourceTree = "<group>"; };
    31033107                2EE4529B20292BD800D81777 /* WKSelectMenuViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKSelectMenuViewController.mm; path = ios/forms/WKSelectMenuViewController.mm; sourceTree = "<group>"; };
    31043108                2EE4529C20292BD900D81777 /* WKSelectMenuViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKSelectMenuViewController.h; path = ios/forms/WKSelectMenuViewController.h; sourceTree = "<group>"; };
     
    83678371                                2E16B6D22017BA37008996D6 /* WKTextSuggestionButton.h */,
    83688372                                2E16B6D32017BA37008996D6 /* WKTextSuggestionButton.mm */,
     8373                                2EB6FBFF203021960017E619 /* WKTimePickerViewController.h */,
     8374                                2EB6FC00203021960017E619 /* WKTimePickerViewController.mm */,
    83698375                        );
    83708376                        name = forms;
     
    95519557                                0FCB4E6818BBE3D9000FCFC9 /* WKTextInputWindowController.h in Headers */,
    95529558                                2E16B6D42017BA37008996D6 /* WKTextSuggestionButton.h in Headers */,
     9559                                2EB6FC01203021960017E619 /* WKTimePickerViewController.h in Headers */,
    95539560                                BC407608124FF0270068F20A /* WKType.h in Headers */,
    95549561                                7CD5EBBF1746B04C000C1C45 /* WKTypeRefWrapper.h in Headers */,
     
    1118111188                                0FCB4E6918BBE3D9000FCFC9 /* WKTextInputWindowController.mm in Sources */,
    1118211189                                2E16B6D52017BA37008996D6 /* WKTextSuggestionButton.mm in Sources */,
     11190                                2EB6FC02203021960017E619 /* WKTimePickerViewController.mm in Sources */,
    1118311191                                BC407607124FF0270068F20A /* WKType.cpp in Sources */,
    1118411192                                7CD5EBBE1746B04C000C1C45 /* WKTypeRefWrapper.mm in Sources */,
Note: See TracChangeset for help on using the changeset viewer.