Changeset 245338 in webkit


Ignore:
Timestamp:
May 15, 2019 12:24:16 PM (5 years ago)
Author:
Wenson Hsieh
Message:

inputmode="numeric" should show a number pad with digits 0-9, instead of the numeric keyplane
https://bugs.webkit.org/show_bug.cgi?id=197916
<rdar://problem/50815427>

Reviewed by Timothy Hatcher.

Source/WebKit:

Use UIKeyboardTypeNumberPad instead of UIKeyboardTypeNumbersAndPunctuation when presenting a keyboard for a
field with inputmode="numeric". While the WhatWG specification merely requires the UA to display a keyboard
"capable of numeric input", it suggests that the keyboard should be "useful for PIN entry", which loosely
implies a number pad.

This is also generally in line with feedback from web developers.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView textInputTraits]):

Tools:

Re-enable this previously flaky test, and rebaseline the result to to expect UIKeyboardTypeNumberPad for
inputmode="numeric".

  • TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r245337 r245338  
     12019-05-15  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        inputmode="numeric" should show a number pad with digits 0-9, instead of the numeric keyplane
     4        https://bugs.webkit.org/show_bug.cgi?id=197916
     5        <rdar://problem/50815427>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Use UIKeyboardTypeNumberPad instead of UIKeyboardTypeNumbersAndPunctuation when presenting a keyboard for a
     10        field with inputmode="numeric". While the WhatWG specification merely requires the UA to display a keyboard
     11        "capable of numeric input", it suggests that the keyboard should be "useful for PIN entry", which loosely
     12        implies a number pad.
     13
     14        This is also generally in line with feedback from web developers.
     15
     16        * UIProcess/ios/WKContentViewInteraction.mm:
     17        (-[WKContentView textInputTraits]):
     18
    1192019-05-15  Don Olmstead  <don.olmstead@sony.com>
    220
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r245283 r245338  
    43814381        break;
    43824382    case WebCore::InputMode::Numeric:
    4383         [_traits setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
     4383        [_traits setKeyboardType:UIKeyboardTypeNumberPad];
    43844384        break;
    43854385    case WebCore::InputMode::Decimal:
  • trunk/Tools/ChangeLog

    r245328 r245338  
     12019-05-15  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        inputmode="numeric" should show a number pad with digits 0-9, instead of the numeric keyplane
     4        https://bugs.webkit.org/show_bug.cgi?id=197916
     5        <rdar://problem/50815427>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Re-enable this previously flaky test, and rebaseline the result to to expect UIKeyboardTypeNumberPad for
     10        inputmode="numeric".
     11
     12        * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
     13        (TestWebKitAPI::TEST):
     14
    1152019-05-15  Youenn Fablet  <youenn@apple.com>
    216
  • trunk/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm

    r244955 r245338  
    360360}
    361361
    362 TEST(KeyboardInputTests, DISABLED_KeyboardTypeForInput)
     362TEST(KeyboardInputTests, KeyboardTypeForInput)
    363363{
    364364    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     
    370370    [webView _setInputDelegate:inputDelegate.get()];
    371371    [webView synchronouslyLoadHTMLString:@"<input id='input'>"];
     372    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"input.focus()"];
    372373
    373374    auto runTest = ^(NSString *inputType, NSString *inputMode, NSString *pattern, UIKeyboardType expectedKeyboardType) {
    374         [webView stringByEvaluatingJavaScript:@"input.blur()"];
    375         [webView stringByEvaluatingJavaScript:[NSString stringWithFormat:@"input.type = '%@'; input.inputMode = '%@'; input.pattern = '%@'", inputType, inputMode, pattern]];
    376         [webView stringByEvaluatingJavaScript:@"input.focus()"];
     375        [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"input.blur()"];
     376        [webView evaluateJavaScriptAndWaitForInputSessionToChange:[NSString stringWithFormat:@"input.type = '%@'; input.inputMode = '%@'; input.pattern = '%@'; input.focus()", inputType, inputMode, pattern]];
    377377
    378378        UIView<UITextInputPrivate> *textInput = (UIView<UITextInputPrivate> *)[webView textInputContentView];
     
    402402        @"url": @(UIKeyboardTypeURL),
    403403        @"email": @(UIKeyboardTypeEmailAddress),
    404         @"numeric": @(UIKeyboardTypeNumbersAndPunctuation),
     404        @"numeric": @(UIKeyboardTypeNumberPad),
    405405        @"decimal": @(UIKeyboardTypeDecimalPad),
    406406        @"search": @(UIKeyboardTypeWebSearch)
     
    413413    };
    414414
    415     for (NSString *inputType in [expectedKeyboardTypeForInputType allKeys]) {
    416         for (NSString *inputMode in [expectedKeyboardTypeForInputMode allKeys]) {
    417             for (NSString *pattern in [expectedKeyboardTypeForPattern allKeys]) {
     415    for (NSString *inputType in expectedKeyboardTypeForInputType) {
     416        BOOL isNumberOrTextInput = [inputType isEqual:@"text"] || [inputType isEqual:@"number"];
     417        for (NSString *inputMode in expectedKeyboardTypeForInputMode) {
     418            for (NSString *pattern in expectedKeyboardTypeForPattern) {
    418419                NSNumber *keyboardType;
    419420                if (inputMode.length) {
     
    421422                    keyboardType = expectedKeyboardTypeForInputMode[inputMode];
    422423                } else {
    423                     if (pattern.length && ([inputType isEqual: @"text"] || [inputType isEqual: @"number"])) {
    424                         // Special case for text and number inputs that have a numeric pattern.
    425                         keyboardType = expectedKeyboardTypeForPattern[pattern];
    426                     } else {
    427                         // Otherwise, the input type determines the keyboard type.
    428                         keyboardType = expectedKeyboardTypeForInputType[inputType];
    429                     }
     424                    // Special case for text and number inputs that have a numeric pattern. Otherwise, the input type determines the keyboard type.
     425                    keyboardType = pattern.length && isNumberOrTextInput ? expectedKeyboardTypeForPattern[pattern] : expectedKeyboardTypeForInputType[inputType];
    430426                }
    431427
Note: See TracChangeset for help on using the changeset viewer.