Bug 183621

Summary: Add support for the `inputmode` attribute
Product: WebKit Reporter: Dayton Lowell <daytonlowell>
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, dave+webkit, dbates, dvpdiner2, feliziani.emanuele, paulirish, pxlcoder, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar, WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
thorton: review+
Patch
none
Patch for landing none

Comment 1 Aditya Keerthi 2018-08-16 19:51:22 PDT
Created attachment 347340 [details]
Patch
Comment 2 Aditya Keerthi 2018-08-17 15:20:40 PDT
Created attachment 347396 [details]
Patch
Comment 3 Aditya Keerthi 2018-08-17 16:48:14 PDT
Created attachment 347413 [details]
Patch
Comment 4 Daniel Bates 2018-08-17 18:57:10 PDT
Comment on attachment 347413 [details]
Patch

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

> Source/WebCore/html/InputModeNames.cpp:77
> +} // namespace WebCore::InputModeNames

// namespace InputModeNames

> Source/WebCore/html/InputModeNames.h:42
> +}

Ditto.

> Source/WebKit/Shared/AssistedNodeInformation.h:61
> +enum class InputMode {

We should specify a size fo this enum to get better packing. Otherwise, this enum will default to the width of int.

> Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:3554
> +        default:

I suggest we remove this "default" case and list any other enumerators. This will allow the compiler to ensure that this switch handles all enumerators.

> Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:2302
> +static InputMode inputModeForElement(const Node& node)

Can we come up with a better name for this?
Comment 5 Wenson Hsieh 2018-08-18 00:22:46 PDT
> duplicate symbol __ZN7WebCore14InputModeNames7numericEv in:
>     /Volumes/Data/EWS/WebKit/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/Objects-normal/x86_64/InputModeNames.o
>     /Volumes/Data/EWS/WebKit/WebKitBuild/WebCore.build/Release-iphonesimulator/WebCore.build/Objects-normal/x86_64/UnifiedSource269.o
> ld: 7 duplicate symbols for architecture x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is InputModeNames.cpp being included in the WebCore target, as well appearing in one of the unified source files?
Comment 6 Aditya Keerthi 2018-08-20 10:04:46 PDT
Created attachment 347504 [details]
Patch
Comment 7 Aditya Keerthi 2018-08-21 16:11:55 PDT
Created attachment 347720 [details]
Patch
Comment 8 Aditya Keerthi 2018-08-21 16:12:50 PDT
Added an API test to verify we show the correct keyboard for a variety of input configurations.
Comment 9 Tim Horton 2018-08-21 16:47:52 PDT
Comment on attachment 347720 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:192
> +    NSArray *inputModes = @[ @"", @"text", @"tel", @"url", @"email", @"numeric", @"decimal", @"search" ];

Could create this from the dictionary with -allKeys. Except "" I guess... I dunno.

> Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:203
> +    NSArray *inputTypesWithKeyboard = @[ @"text", @"password", @"search", @"email", @"tel", @"number", @"url" ];

Could create this from the dictionary with -allKeys
Comment 10 Aditya Keerthi 2018-08-22 09:48:30 PDT
Created attachment 347812 [details]
Patch
Comment 11 Aditya Keerthi 2018-08-22 10:46:20 PDT
Created attachment 347820 [details]
Patch for landing
Comment 12 WebKit Commit Bot 2018-08-22 14:22:20 PDT
Comment on attachment 347820 [details]
Patch for landing

Clearing flags on attachment: 347820

Committed r235201: <https://trac.webkit.org/changeset/235201>
Comment 13 Daniel Bates 2018-08-22 15:38:59 PDT
Comment on attachment 347820 [details]
Patch for landing

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

> Source/WebCore/ChangeLog:8
> +        Added the inputmode attribute to the HTMLInputElement and HTMLTextAreaElement IDL

It is an unwritten convention that we reference the spec. and version/date of the spec. in the ChangeLog when adding new web exposed functionality. One example of such a ChangeLog (though it does not include a date) is <https://trac.webkit.org/changeset/234680/>. This records the spec you referenced when writing this patch.

> Source/WebCore/html/HTMLTextAreaElement.idl:62
> +    attribute DOMString inputMode;

As per <https://html.spec.whatwg.org/multipage/interaction.html#dom-inputmode> this should be a reflected attribute. Please add "[Reflect]" before "attribute".

> Source/WebCore/html/HTMLTextFormControlElement.cpp:678
> +String HTMLTextFormControlElement::inputMode() const

How did you come to the decision to return a String instead of returning an const AtomicString&? I mean, returning a String causes unnecessary ref-count churn.

> Source/WebCore/html/HTMLTextFormControlElement.cpp:702
> +void HTMLTextFormControlElement::setInputMode(const String& value)
> +{
> +    setAttributeWithoutSynchronization(inputmodeAttr, value);
> +}

This function is unnecessary when the attribute is marked "[Reflect]" in the IDL.
Comment 14 Radar WebKit Bug Importer 2018-08-22 15:42:16 PDT
<rdar://problem/43623657>
Comment 15 Daniel Bates 2018-08-22 16:09:06 PDT
(In reply to Daniel Bates from comment #13)
> > Source/WebCore/html/HTMLTextAreaElement.idl:62
> > +    attribute DOMString inputMode;
> 
> As per
> <https://html.spec.whatwg.org/multipage/interaction.html#dom-inputmode> this
> should be a reflected attribute. Please add "[Reflect]" before "attribute".
> 

Disregard this remark. Our binding generator code does not support reflections with a custom getter.

> [...]
> 
> > Source/WebCore/html/HTMLTextFormControlElement.cpp:702
> > +void HTMLTextFormControlElement::setInputMode(const String& value)
> > +{
> > +    setAttributeWithoutSynchronization(inputmodeAttr, value);
> > +}
> 
> This function is unnecessary when the attribute is marked "[Reflect]" in the
> IDL.


Disregard this remark.
Comment 16 David Tapuska 2018-08-22 17:08:45 PDT
So looking at the patch set it looks like you might have only implemented half of it. There doesn't seem to be any "none" support and this is missing the attribute on the HTML element which is useful for content editable. 

Is this really resolved fixed? Or are more patches coming? If not can you share justification for diverging from the specification?
Comment 17 Aditya Keerthi 2018-08-22 17:14:10 PDT
(In reply to David Tapuska from comment #16)
> So looking at the patch set it looks like you might have only implemented
> half of it. There doesn't seem to be any "none" support and this is missing
> the attribute on the HTML element which is useful for content editable. 
> 
> Is this really resolved fixed? Or are more patches coming? If not can you
> share justification for diverging from the specification?

I have a patch forthcoming for the contenteditable case.
Comment 18 David Tapuska 2018-08-22 17:22:47 PDT
None support is used by some of Google's productivity apps that have a content editable item but don't wish a keyboard to be present. For example presentation mode in Google Slides.
Comment 19 Darryl Pogue 2018-08-22 23:52:00 PDT
*** Bug 161506 has been marked as a duplicate of this bug. ***
Comment 20 Emanuele Feliziani 2018-11-30 00:28:47 PST
Hello

This has been shipped in Chrome and I see it has been marked as fixed here for months. I am writing this hoping it gets noticed by someone who can verify it so it can make its way into Safari soon enough.

Many thanks everyone.
Comment 21 Dayton Lowell 2019-01-30 09:21:47 PST
Emanuele,

This will ship in iOS 12.2, which is currently in beta.
Comment 22 Emanuele Feliziani 2019-01-31 10:33:20 PST
Best news of the week. Thanks!