⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 251720 in webkit


Ignore:
Timestamp:
Oct 29, 2019, 12:39:47 PM (7 years ago)
Author:
Wenson Hsieh
Message:

Add enterkeyhint support
https://bugs.webkit.org/show_bug.cgi?id=189546
<rdar://problem/51021148>

Reviewed by Tim Horton.

Source/WebCore:

  • Headers.cmake: Add EnterKeyHint.h.

Source/WebKit:

This patch adds support for the enterkeyhint HTML attribute on iOS.

Tests: EnterKeyHintTests.EnterKeyHintInContentEditableElement

EnterKeyHintTests.EnterKeyHintInTextInput
EnterKeyHintTests.EnterKeyHintInTextArea

  • Shared/FocusedElementInformation.cpp:

(WebKit::FocusedElementInformation::encode const):
(WebKit::FocusedElementInformation::decode):

  • Shared/FocusedElementInformation.h:

Add a new flag to FocusedElementInformation to indicate the EnterKeyHint type that should be used when bringing
up an input view for the focused element.

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView textInputTraits]):

Map the given EnterKeyHint type to a UIReturnKeyType. If an unsupported (i.e. "previous") or default
EnterKeyHint value is used, then we fall back to existing behavior which deduces the default enterkeyhint value
from the input type if the focused element is inside an actionable form; otherwise, we avoid setting any value
for the returnKeyType, defaulting to UIReturnKeyDefault.

  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::getFocusedElementInformation):

Tools:

Add new API tests to check the resulting UIReturnKeyType that gets set on text input traits in the UI process,
given the different values for "enterkeyhint". Also verifies that the default behaviors of search fields and
text input fields inside actionable form elements is to show "Search" or "Go" as the return key by default,
unless a different value for "enterkeyhint" is specified.

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/ios/EnterKeyHintTests.mm: Added.

(-[TestWKWebView test:enterKeyHint:returnKeyType:]):
(TestWebKitAPI::enterKeyHintTestCases):
(TestWebKitAPI::createWebViewAndInputDelegateForTesting):
(TestWebKitAPI::TEST):

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r251718 r251720  
     12019-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add enterkeyhint support
     4        https://bugs.webkit.org/show_bug.cgi?id=189546
     5        <rdar://problem/51021148>
     6
     7        Reviewed by Tim Horton.
     8
     9        * Headers.cmake: Add EnterKeyHint.h.
     10
    1112019-10-29  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebCore/Headers.cmake

    r251655 r251720  
    542542    html/DOMTokenList.h
    543543    html/DataListSuggestionInformation.h
     544    html/EnterKeyHint.h
    544545    html/FeaturePolicy.h
    545546    html/FormAssociatedElement.h
  • trunk/Source/WebKit/ChangeLog

    r251719 r251720  
     12019-10-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add enterkeyhint support
     4        https://bugs.webkit.org/show_bug.cgi?id=189546
     5        <rdar://problem/51021148>
     6
     7        Reviewed by Tim Horton.
     8
     9        This patch adds support for the enterkeyhint HTML attribute on iOS.
     10
     11        Tests:  EnterKeyHintTests.EnterKeyHintInContentEditableElement
     12                EnterKeyHintTests.EnterKeyHintInTextInput
     13                EnterKeyHintTests.EnterKeyHintInTextArea
     14
     15        * Shared/FocusedElementInformation.cpp:
     16        (WebKit::FocusedElementInformation::encode const):
     17        (WebKit::FocusedElementInformation::decode):
     18        * Shared/FocusedElementInformation.h:
     19
     20        Add a new flag to FocusedElementInformation to indicate the EnterKeyHint type that should be used when bringing
     21        up an input view for the focused element.
     22
     23        * UIProcess/ios/WKContentViewInteraction.mm:
     24        (-[WKContentView textInputTraits]):
     25
     26        Map the given EnterKeyHint type to a UIReturnKeyType. If an unsupported (i.e. "previous") or default
     27        EnterKeyHint value is used, then we fall back to existing behavior which deduces the default enterkeyhint value
     28        from the input type if the focused element is inside an actionable form; otherwise, we avoid setting any value
     29        for the `returnKeyType`, defaulting to `UIReturnKeyDefault`.
     30
     31        * WebProcess/WebPage/ios/WebPageIOS.mm:
     32        (WebKit::WebPage::getFocusedElementInformation):
     33
    1342019-10-29  Kate Cheney  <katherine_cheney@apple.com>
    235
  • trunk/Source/WebKit/Shared/FocusedElementInformation.cpp

    r251693 r251720  
    8080    encoder.encodeEnum(elementType);
    8181    encoder.encodeEnum(inputMode);
     82    encoder.encodeEnum(enterKeyHint);
    8283    encoder << formAction;
    8384    encoder << selectOptions;
     
    163164        return false;
    164165
     166    if (!decoder.decodeEnum(result.enterKeyHint))
     167        return false;
     168
    165169    if (!decoder.decode(result.formAction))
    166170        return false;
  • trunk/Source/WebKit/Shared/FocusedElementInformation.h

    r251693 r251720  
    3131#include <WebCore/Color.h>
    3232#include <WebCore/ElementContext.h>
     33#include <WebCore/EnterKeyHint.h>
    3334#include <WebCore/GraphicsLayer.h>
    3435#include <WebCore/InputMode.h>
     
    119120    InputType elementType { InputType::None };
    120121    WebCore::InputMode inputMode { WebCore::InputMode::Unspecified };
     122    WebCore::EnterKeyHint enterKeyHint { WebCore::EnterKeyHint::Unspecified };
    121123    String formAction;
    122124    Vector<OptionItem> selectOptions;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r251693 r251720  
    47104710    [_traits setShortcutConversionType:_focusedElementInformation.elementType == WebKit::InputType::Password ? UITextShortcutConversionTypeNo : UITextShortcutConversionTypeDefault];
    47114711
    4712     if (!_focusedElementInformation.formAction.isEmpty())
    4713         [_traits setReturnKeyType:(_focusedElementInformation.elementType == WebKit::InputType::Search) ? UIReturnKeySearch : UIReturnKeyGo];
     4712    switch (_focusedElementInformation.enterKeyHint) {
     4713    case WebCore::EnterKeyHint::Enter:
     4714        [_traits setReturnKeyType:UIReturnKeyDefault];
     4715        break;
     4716    case WebCore::EnterKeyHint::Done:
     4717        [_traits setReturnKeyType:UIReturnKeyDone];
     4718        break;
     4719    case WebCore::EnterKeyHint::Go:
     4720        [_traits setReturnKeyType:UIReturnKeyGo];
     4721        break;
     4722    case WebCore::EnterKeyHint::Next:
     4723        [_traits setReturnKeyType:UIReturnKeyNext];
     4724        break;
     4725    case WebCore::EnterKeyHint::Search:
     4726        [_traits setReturnKeyType:UIReturnKeySearch];
     4727        break;
     4728    case WebCore::EnterKeyHint::Send:
     4729        [_traits setReturnKeyType:UIReturnKeySend];
     4730        break;
     4731    default: {
     4732        if (!_focusedElementInformation.formAction.isEmpty())
     4733            [_traits setReturnKeyType:_focusedElementInformation.elementType == WebKit::InputType::Search ? UIReturnKeySearch : UIReturnKeyGo];
     4734    }
     4735    }
    47144736
    47154737    if (_focusedElementInformation.elementType == WebKit::InputType::Password || _focusedElementInformation.elementType == WebKit::InputType::Email || _focusedElementInformation.elementType == WebKit::InputType::URL || _focusedElementInformation.formAction.contains("login")) {
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r251693 r251720  
    29882988        information.placeholder = element.attributeWithoutSynchronization(HTMLNames::placeholderAttr);
    29892989        information.inputMode = element.canonicalInputMode();
     2990        information.enterKeyHint = element.canonicalEnterKeyHint();
    29902991    } else if (is<HTMLInputElement>(*m_focusedElement)) {
    29912992        HTMLInputElement& element = downcast<HTMLInputElement>(*m_focusedElement);
     
    30493050#endif
    30503051        information.inputMode = element.canonicalInputMode();
     3052        information.enterKeyHint = element.canonicalEnterKeyHint();
    30513053        information.isReadOnly = element.isReadOnly();
    30523054        information.value = element.value();
     
    30633065            information.autocapitalizeType = focusedElement.autocapitalizeType();
    30643066            information.inputMode = focusedElement.canonicalInputMode();
     3067            information.enterKeyHint = focusedElement.canonicalEnterKeyHint();
    30653068            information.shouldSynthesizeKeyEventsForEditing = focusedElement.document().settings().syntheticEditingCommandsEnabled();
    30663069        } else {
  • trunk/Tools/ChangeLog

    r251712 r251720  
     12019-10-27  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add enterkeyhint support
     4        https://bugs.webkit.org/show_bug.cgi?id=189546
     5        <rdar://problem/51021148>
     6
     7        Reviewed by Tim Horton.
     8
     9        Add new API tests to check the resulting UIReturnKeyType that gets set on text input traits in the UI process,
     10        given the different values for "enterkeyhint". Also verifies that the default behaviors of search fields and
     11        text input fields inside actionable form elements is to show "Search" or "Go" as the return key by default,
     12        unless a different value for "enterkeyhint" is specified.
     13
     14        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     15        * TestWebKitAPI/Tests/ios/EnterKeyHintTests.mm: Added.
     16        (-[TestWKWebView test:enterKeyHint:returnKeyType:]):
     17        (TestWebKitAPI::enterKeyHintTestCases):
     18        (TestWebKitAPI::createWebViewAndInputDelegateForTesting):
     19        (TestWebKitAPI::TEST):
     20
    1212019-10-29  Truitt Savell  <tsavell@apple.com>
    222
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r251709 r251720  
    10331033                F4CD74C620FDACFA00DE3794 /* text-with-async-script.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4CD74C520FDACF500DE3794 /* text-with-async-script.html */; };
    10341034                F4CD74C920FDB49600DE3794 /* TestURLSchemeHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */; };
     1035                F4CF32802366552200D3AD07 /* EnterKeyHintTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4CF327F2366552200D3AD07 /* EnterKeyHintTests.mm */; };
    10351036                F4D2986E20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D2986D20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm */; };
    10361037                F4D4F3B61E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm */; };
     
    25582559                F4CD74C820FDB49600DE3794 /* TestURLSchemeHandler.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestURLSchemeHandler.mm; sourceTree = "<group>"; };
    25592560                F4CDAB3322489FE10057A2D9 /* IPadUserInterfaceSwizzler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IPadUserInterfaceSwizzler.h; sourceTree = "<group>"; };
     2561                F4CF327F2366552200D3AD07 /* EnterKeyHintTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = EnterKeyHintTests.mm; sourceTree = "<group>"; };
    25602562                F4D2986D20FEE7370092D636 /* RunScriptAfterDocumentLoad.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RunScriptAfterDocumentLoad.mm; sourceTree = "<group>"; };
    25612563                F4D4F3B41E4E2BCB00BB2767 /* DragAndDropSimulatorIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropSimulatorIOS.mm; sourceTree = "<group>"; };
     
    31373139                                44077BB0231449D200179E2D /* DataDetectorsTestIOS.mm */,
    31383140                                F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */,
     3141                                F4CF327F2366552200D3AD07 /* EnterKeyHintTests.mm */,
    31393142                                F4BC0B132146C849002A0478 /* FocusPreservationTests.mm */,
    31403143                                CDA93DAC22F4EC2200490A69 /* FullscreenTouchSecheuristicTests.cpp */,
     
    45674570                                F44D06471F39627A001A0E29 /* EditorStateTests.mm in Sources */,
    45684571                                7CCE7EBF1A411A7E00447C4C /* ElementAtPointInWebFrame.mm in Sources */,
     4572                                F4CF32802366552200D3AD07 /* EnterKeyHintTests.mm in Sources */,
    45694573                                07492B3B1DF8B14C00633DE1 /* EnumerateMediaDevices.cpp in Sources */,
    45704574                                448D7E471EA6C55500ECC756 /* EnvironmentUtilitiesTest.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.