WebKit Bugzilla
Attachment 347504 Details for
Bug 183621
: Add support for the `inputmode` attribute
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-183621-20180820100446.patch (text/plain), 29.80 KB, created by
Aditya Keerthi
on 2018-08-20 10:04:46 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Aditya Keerthi
Created:
2018-08-20 10:04:46 PDT
Size:
29.80 KB
patch
obsolete
>Subversion Revision: 235065 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 70bd1a9cd7558064b57c991ae1cbb4050ab43f7a..d390733402e391b0c78e97a41b3b4bcac5e0bd04 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2018-08-20 Aditya Keerthi <akeerthi@apple.com> >+ >+ [iOS] Add support for the inputmode attribute >+ https://bugs.webkit.org/show_bug.cgi?id=183621 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added the inputmode attribute to the HTMLInputElement and HTMLTextAreaElement IDL >+ files. The possible values for the attribute are specified in InputModeNames. >+ >+ Test: fast/forms/inputmode-attribute.html >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * html/HTMLAttributeNames.in: >+ * html/HTMLInputElement.idl: >+ * html/HTMLTextAreaElement.idl: >+ * html/HTMLTextFormControlElement.cpp: >+ (WebCore::HTMLTextFormControlElement::inputMode const): >+ (WebCore::HTMLTextFormControlElement::setInputMode): >+ * html/HTMLTextFormControlElement.h: >+ * html/InputModeNames.cpp: Added. >+ (WebCore::InputModeNames::text): >+ (WebCore::InputModeNames::tel): >+ (WebCore::InputModeNames::url): >+ (WebCore::InputModeNames::email): >+ (WebCore::InputModeNames::numeric): >+ (WebCore::InputModeNames::decimal): >+ (WebCore::InputModeNames::search): >+ * html/InputModeNames.h: Added. >+ > 2018-08-20 Rob Buis <rbuis@igalia.com> > > Throw an exception if window.open() gets passed a URL that cannot be parsed >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 65f4f102ac5f23d0bbaab46c05b406eb0ed4a9bb..50255d63d43d6a8f592926ee7d16521a7ca95631 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,36 @@ >+2018-08-20 Aditya Keerthi <akeerthi@apple.com> >+ >+ [iOS] Add support for the inputmode attribute >+ https://bugs.webkit.org/show_bug.cgi?id=183621 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The inputmode attribute specifies which input mechanism would be most helpful for >+ users entering content in textfield inputs and textareas. This patch adds support >+ for seven values: text, tel, url, email, numeric, decimal and search. >+ >+ On iOS, we can specify UIKeyboardTypes that best match the supplied inputmode. >+ - text: UIKeyboardTypeDefault >+ - tel: UIKeyboardTypePhonePad >+ - url: UIKeyboardTypeURL >+ - email: UIKeyboardTypeEmailAddress >+ - numeric: UIKeyboardTypeNumberPad >+ - decimal: UIKeyboardTypeDecimalPad >+ - search: UIKeyboardTypeWebSearch >+ >+ In the case that the inputmode attribute is not specified, we fall back to using >+ our existing heuristic to determine what kind of keyboard to show for textfields. >+ >+ * Shared/AssistedNodeInformation.cpp: >+ (WebKit::AssistedNodeInformation::encode const): >+ (WebKit::AssistedNodeInformation::decode): >+ * Shared/AssistedNodeInformation.h: Added inputMode field. >+ * UIProcess/ios/WKContentViewInteraction.mm: >+ (-[WKContentView textInputTraits]): >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::inputModeForElement): >+ (WebKit::WebPage::getAssistedNodeInformation): >+ > 2018-08-20 Carlos Garcia Campos <cgarcia@igalia.com> > > Unreviewed. Fix GTK/WPE cookie API tests after r234396. >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index f0ef78610dd046b367272c05aac6744585c938a2..8de8e176fc4c4250f21eaf0bc6edfc45fb78e169 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -1056,6 +1056,7 @@ html/ImageBitmap.cpp > html/ImageData.cpp > html/ImageDocument.cpp > html/ImageInputType.cpp >+html/InputModeNames.cpp > html/InputType.cpp > html/InputTypeNames.cpp > html/LabelableElement.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index e996fed47c89810aeb8e9456221bc8d6ca450314..8a044eca0b240afa695dc80ec4c5877d8eea0c98 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -4790,6 +4790,7 @@ > E517670320B88C1400D41167 /* DataListSuggestionInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = E517670220B88C1400D41167 /* DataListSuggestionInformation.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E52CF54D20A268AC00DADA27 /* DataListSuggestionsClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF54C20A268AC00DADA27 /* DataListSuggestionsClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E52CF54F20A35A2800DADA27 /* DataListSuggestionPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF54E20A35A2800DADA27 /* DataListSuggestionPicker.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ E52EFDF42112875A00AD282A /* InputModeNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E52EFDF22112875A00AD282A /* InputModeNames.h */; settings = {ATTRIBUTES = (Private, ); }; }; > E58B45BA20AD07DD00991025 /* DataListButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E58B45B820AD07DD00991025 /* DataListButtonElement.h */; }; > E58B45BB20AD07DD00991025 /* DataListButtonElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E58B45B920AD07DD00991025 /* DataListButtonElement.cpp */; }; > E59DD4B821098287003C8B47 /* ListButtonArrow.png in Resources */ = {isa = PBXBuildFile; fileRef = E59DD4B721098285003C8B47 /* ListButtonArrow.png */; }; >@@ -14524,6 +14525,8 @@ > E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; }; > E52CF54C20A268AC00DADA27 /* DataListSuggestionsClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionsClient.h; sourceTree = "<group>"; }; > E52CF54E20A35A2800DADA27 /* DataListSuggestionPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionPicker.h; sourceTree = "<group>"; }; >+ E52EFDF22112875A00AD282A /* InputModeNames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InputModeNames.h; sourceTree = "<group>"; }; >+ E52EFDF32112875A00AD282A /* InputModeNames.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InputModeNames.cpp; sourceTree = "<group>"; }; > E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; }; > E58B45B820AD07DD00991025 /* DataListButtonElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListButtonElement.h; sourceTree = "<group>"; }; > E58B45B920AD07DD00991025 /* DataListButtonElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DataListButtonElement.cpp; sourceTree = "<group>"; }; >@@ -20806,6 +20809,8 @@ > 97205AB21239291000B17380 /* ImageDocument.h */, > F55B3D8D1251F12D003EF269 /* ImageInputType.cpp */, > F55B3D8E1251F12D003EF269 /* ImageInputType.h */, >+ E52EFDF32112875A00AD282A /* InputModeNames.cpp */, >+ E52EFDF22112875A00AD282A /* InputModeNames.h */, > 37E3524A12450C5200BAF5D9 /* InputType.cpp */, > 37E3524C12450C6600BAF5D9 /* InputType.h */, > C348612115FDE21E007A1CC9 /* InputTypeNames.cpp */, >@@ -28437,6 +28442,7 @@ > 1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */, > 510A58E51BAA40B100C19282 /* InProcessIDBServer.h in Headers */, > 2EB767571DA19BDF003E23B5 /* InputEvent.h in Headers */, >+ E52EFDF42112875A00AD282A /* InputModeNames.h in Headers */, > 37E3524D12450C6600BAF5D9 /* InputType.h in Headers */, > C348612415FDE21E007A1CC9 /* InputTypeNames.h in Headers */, > 93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */, >diff --git a/Source/WebCore/html/HTMLAttributeNames.in b/Source/WebCore/html/HTMLAttributeNames.in >index 6e665047ed58574616e9bdc6f1c4ca1917f4e224..794b774e2e46d3f65e76598fb4a609a03b8d4b81 100644 >--- a/Source/WebCore/html/HTMLAttributeNames.in >+++ b/Source/WebCore/html/HTMLAttributeNames.in >@@ -144,6 +144,7 @@ http_equiv > id > incremental > indeterminate >+inputmode > integrity > is > ismap >diff --git a/Source/WebCore/html/HTMLInputElement.idl b/Source/WebCore/html/HTMLInputElement.idl >index e9658294f101badd4b744105e1d1d2dd6e29a150..b06f9c4756f7d515533073447409f7b7beff52a9 100644 >--- a/Source/WebCore/html/HTMLInputElement.idl >+++ b/Source/WebCore/html/HTMLInputElement.idl >@@ -42,6 +42,7 @@ > [Reflect] attribute DOMString formTarget; > attribute unsigned long height; > attribute boolean indeterminate; >+ attribute DOMString inputMode; > [Conditional=DATALIST_ELEMENT] readonly attribute HTMLElement list; > [Reflect] attribute DOMString max; > attribute long minLength; >diff --git a/Source/WebCore/html/HTMLTextAreaElement.idl b/Source/WebCore/html/HTMLTextAreaElement.idl >index b8540165275e1cd3774583a4b7c7a67d81b22b93..bda362abf3e9b399783d4ce389545e266dff82a5 100644 >--- a/Source/WebCore/html/HTMLTextAreaElement.idl >+++ b/Source/WebCore/html/HTMLTextAreaElement.idl >@@ -59,4 +59,5 @@ interface HTMLTextAreaElement : HTMLElement { > void setSelectionRange(optional long start = 0, optional long end = 0, optional DOMString direction); > > attribute DOMString autocomplete; >+ attribute DOMString inputMode; > }; >diff --git a/Source/WebCore/html/HTMLTextFormControlElement.cpp b/Source/WebCore/html/HTMLTextFormControlElement.cpp >index 94eab766e26785999adf1d200841dd88b9ef6cbb..033268a39e3d66bf0f02ce9c6efc64a7fc7be694 100644 >--- a/Source/WebCore/html/HTMLTextFormControlElement.cpp >+++ b/Source/WebCore/html/HTMLTextFormControlElement.cpp >@@ -39,6 +39,7 @@ > #include "HTMLInputElement.h" > #include "HTMLNames.h" > #include "HTMLParserIdioms.h" >+#include "InputModeNames.h" > #include "LayoutDisallowedScope.h" > #include "Logging.h" > #include "NodeTraversal.h" >@@ -674,6 +675,32 @@ void HTMLTextFormControlElement::showPlaceholderIfNecessary() > } > #endif > >+String HTMLTextFormControlElement::inputMode() const >+{ >+ const AtomicString& inputMode = attributeWithoutSynchronization(inputmodeAttr); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::text())) >+ return InputModeNames::text(); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::tel())) >+ return InputModeNames::tel(); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::url())) >+ return InputModeNames::url(); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::email())) >+ return InputModeNames::email(); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::numeric())) >+ return InputModeNames::numeric(); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::decimal())) >+ return InputModeNames::decimal(); >+ if (equalIgnoringASCIICase(inputMode, InputModeNames::search())) >+ return InputModeNames::search(); >+ >+ return emptyString(); >+} >+ >+void HTMLTextFormControlElement::setInputMode(const String& value) >+{ >+ setAttributeWithoutSynchronization(inputmodeAttr, value); >+} >+ > static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& breakOffset) > { > RootInlineBox* next; >diff --git a/Source/WebCore/html/HTMLTextFormControlElement.h b/Source/WebCore/html/HTMLTextFormControlElement.h >index c320f2fe993d81a423cc599363fb3b33d1cc05fc..7eac0b6c1478062b8ed70b8a136b4d874c0791af 100644 >--- a/Source/WebCore/html/HTMLTextFormControlElement.h >+++ b/Source/WebCore/html/HTMLTextFormControlElement.h >@@ -98,6 +98,9 @@ public: > WEBCORE_EXPORT void showPlaceholderIfNecessary(); > #endif > >+ WEBCORE_EXPORT String inputMode() const; >+ void setInputMode(const String&); >+ > protected: > HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*); > bool isPlaceholderEmpty() const; >diff --git a/Source/WebCore/html/InputModeNames.cpp b/Source/WebCore/html/InputModeNames.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..61c9870773fa741ea6b065476838431681a5319d >--- /dev/null >+++ b/Source/WebCore/html/InputModeNames.cpp >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "InputModeNames.h" >+ >+#include <wtf/NeverDestroyed.h> >+ >+namespace WebCore { >+ >+namespace InputModeNames { >+ >+const AtomicString& text() >+{ >+ static NeverDestroyed<AtomicString> mode("text", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+const AtomicString& tel() >+{ >+ static NeverDestroyed<AtomicString> mode("tel", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+const AtomicString& url() >+{ >+ static NeverDestroyed<AtomicString> mode("url", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+const AtomicString& email() >+{ >+ static NeverDestroyed<AtomicString> mode("email", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+const AtomicString& numeric() >+{ >+ static NeverDestroyed<AtomicString> mode("numeric", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+const AtomicString& decimal() >+{ >+ static NeverDestroyed<AtomicString> mode("decimal", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+const AtomicString& search() >+{ >+ static NeverDestroyed<AtomicString> mode("search", AtomicString::ConstructFromLiteral); >+ return mode; >+} >+ >+} // namespace InputModeNames >+ >+} // namespace WebCore >diff --git a/Source/WebCore/html/InputModeNames.h b/Source/WebCore/html/InputModeNames.h >new file mode 100644 >index 0000000000000000000000000000000000000000..caa259dc3859a35fd72af1b0394d9eb222523e61 >--- /dev/null >+++ b/Source/WebCore/html/InputModeNames.h >@@ -0,0 +1,44 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include <wtf/text/AtomicString.h> >+ >+namespace WebCore { >+ >+namespace InputModeNames { >+ >+WEBCORE_EXPORT const AtomicString& text(); >+WEBCORE_EXPORT const AtomicString& tel(); >+WEBCORE_EXPORT const AtomicString& url(); >+WEBCORE_EXPORT const AtomicString& email(); >+WEBCORE_EXPORT const AtomicString& numeric(); >+WEBCORE_EXPORT const AtomicString& decimal(); >+WEBCORE_EXPORT const AtomicString& search(); >+ >+} // namespace InputModeNames >+ >+} // namespace WebCore >diff --git a/Source/WebKit/Shared/AssistedNodeInformation.cpp b/Source/WebKit/Shared/AssistedNodeInformation.cpp >index 79adb680fe47121d129f9241d7e66afb2abed0d5..210973be5a99c93e7e3c2970cd69e275874b5f0e 100644 >--- a/Source/WebKit/Shared/AssistedNodeInformation.cpp >+++ b/Source/WebKit/Shared/AssistedNodeInformation.cpp >@@ -77,6 +77,7 @@ void AssistedNodeInformation::encode(IPC::Encoder& encoder) const > encoder << isRTL; > encoder.encodeEnum(autocapitalizeType); > encoder.encodeEnum(elementType); >+ encoder.encodeEnum(inputMode); > encoder << formAction; > encoder << selectOptions; > encoder << selectedIndex; >@@ -145,6 +146,9 @@ bool AssistedNodeInformation::decode(IPC::Decoder& decoder, AssistedNodeInformat > if (!decoder.decodeEnum(result.elementType)) > return false; > >+ if (!decoder.decodeEnum(result.inputMode)) >+ return false; >+ > if (!decoder.decode(result.formAction)) > return false; > >diff --git a/Source/WebKit/Shared/AssistedNodeInformation.h b/Source/WebKit/Shared/AssistedNodeInformation.h >index 1e7aac77b008194d19418404116cea24a1ce31fd..0bc8fd3537b03a9eb2774ae6bc63da8183f1bcb7 100644 >--- a/Source/WebKit/Shared/AssistedNodeInformation.h >+++ b/Source/WebKit/Shared/AssistedNodeInformation.h >@@ -59,6 +59,17 @@ enum class InputType { > #endif > }; > >+enum class InputMode : uint8_t { >+ Auto, >+ Text, >+ Telephone, >+ Url, >+ Email, >+ Numeric, >+ Decimal, >+ Search >+}; >+ > #if PLATFORM(IOS) > struct OptionItem { > OptionItem() { } >@@ -110,6 +121,7 @@ struct AssistedNodeInformation { > bool insideFixedPosition { false }; > AutocapitalizeType autocapitalizeType { AutocapitalizeTypeDefault }; > InputType elementType { InputType::None }; >+ InputMode inputMode { InputMode::Auto }; > String formAction; > Vector<OptionItem> selectOptions; > int selectedIndex { -1 }; >diff --git a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >index e829d450125f07c8523a739360a8016566a1f968..a8d7e1b8f056566a2f7dd467571f9e9b411c0479 100644 >--- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >+++ b/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm >@@ -3547,24 +3547,64 @@ static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName) > [_traits setAutocorrectionType:_assistedNodeInformation.isAutocorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo]; > } > >- switch (_assistedNodeInformation.elementType) { >- case InputType::Phone: >+ switch (_assistedNodeInformation.inputMode) { >+ case InputMode::Auto: >+ switch (_assistedNodeInformation.elementType) { >+ case InputType::Phone: >+ [_traits setKeyboardType:UIKeyboardTypePhonePad]; >+ break; >+ case InputType::URL: >+ [_traits setKeyboardType:UIKeyboardTypeURL]; >+ break; >+ case InputType::Email: >+ [_traits setKeyboardType:UIKeyboardTypeEmailAddress]; >+ break; >+ case InputType::Number: >+ [_traits setKeyboardType:UIKeyboardTypeNumbersAndPunctuation]; >+ break; >+ case InputType::NumberPad: >+ [_traits setKeyboardType:UIKeyboardTypeNumberPad]; >+ break; >+ case InputType::None: >+ case InputType::ContentEditable: >+ case InputType::Text: >+ case InputType::Password: >+ case InputType::TextArea: >+ case InputType::Search: >+ case InputType::Date: >+ case InputType::DateTime: >+ case InputType::DateTimeLocal: >+ case InputType::Month: >+ case InputType::Week: >+ case InputType::Time: >+ case InputType::Select: >+#if ENABLE(INPUT_TYPE_COLOR) >+ case InputType::Color: >+#endif >+ [_traits setKeyboardType:UIKeyboardTypeDefault]; >+ } >+ break; >+ case InputMode::Text: >+ [_traits setKeyboardType:UIKeyboardTypeDefault]; >+ break; >+ case InputMode::Telephone: > [_traits setKeyboardType:UIKeyboardTypePhonePad]; > break; >- case InputType::URL: >+ case InputMode::Url: > [_traits setKeyboardType:UIKeyboardTypeURL]; > break; >- case InputType::Email: >+ case InputMode::Email: > [_traits setKeyboardType:UIKeyboardTypeEmailAddress]; > break; >- case InputType::Number: >- [_traits setKeyboardType:UIKeyboardTypeNumbersAndPunctuation]; >- break; >- case InputType::NumberPad: >+ case InputMode::Numeric: > [_traits setKeyboardType:UIKeyboardTypeNumberPad]; > break; >- default: >- [_traits setKeyboardType:UIKeyboardTypeDefault]; >+ case InputMode::Decimal: >+ [_traits setKeyboardType:UIKeyboardTypeDecimalPad]; >+ break; >+ case InputMode::Search: >+ [_traits setKeyboardType:UIKeyboardTypeWebSearch]; >+ break; > } > > [_traits setTextContentType:contentTypeFromFieldName(_assistedNodeInformation.autofillFieldName)]; >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index 26186fb9870e17e45056bca0392baaf485bfff61..7bfa9aa78253a59ef8ad2cb04bd8a8c11525eeb0 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -84,8 +84,10 @@ > #import <WebCore/HTMLParserIdioms.h> > #import <WebCore/HTMLSelectElement.h> > #import <WebCore/HTMLTextAreaElement.h> >+#import <WebCore/HTMLTextFormControlElement.h> > #import <WebCore/HistoryItem.h> > #import <WebCore/HitTestResult.h> >+#import <WebCore/InputModeNames.h> > #import <WebCore/KeyboardEvent.h> > #import <WebCore/LibWebRTCProvider.h> > #import <WebCore/MediaSessionManagerIOS.h> >@@ -2297,6 +2299,27 @@ static IntRect elementRectInRootViewCoordinates(const Node& node, const Frame& f > return view->contentsToRootView(renderer->absoluteBoundingBoxRect()); > } > >+static InputMode inputModeForAssistedNode(const Node& node) >+{ >+ const AtomicString& inputMode = downcast<HTMLTextFormControlElement>(node).inputMode(); >+ if (inputMode == InputModeNames::text()) >+ return InputMode::Text; >+ if (inputMode == InputModeNames::tel()) >+ return InputMode::Telephone; >+ if (inputMode == InputModeNames::url()) >+ return InputMode::Url; >+ if (inputMode == InputModeNames::email()) >+ return InputMode::Email; >+ if (inputMode == InputModeNames::numeric()) >+ return InputMode::Numeric; >+ if (inputMode == InputModeNames::decimal()) >+ return InputMode::Decimal; >+ if (inputMode == InputModeNames::search()) >+ return InputMode::Search; >+ >+ return InputMode::Auto; >+} >+ > void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information) > { > layoutIfNeeded(); >@@ -2402,6 +2425,7 @@ void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information) > information.value = element.value(); > information.autofillFieldName = WebCore::toAutofillFieldName(element.autofillData().fieldName); > information.placeholder = element.attributeWithoutSynchronization(HTMLNames::placeholderAttr); >+ information.inputMode = inputModeForAssistedNode(element); > } else if (is<HTMLInputElement>(*m_assistedNode)) { > HTMLInputElement& element = downcast<HTMLInputElement>(*m_assistedNode); > HTMLFormElement* form = element.form(); >@@ -2459,6 +2483,7 @@ void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information) > } > #endif > >+ information.inputMode = inputModeForAssistedNode(element); > information.isReadOnly = element.isReadOnly(); > information.value = element.value(); > information.valueAsNumber = element.valueAsNumber(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 9d62327c7eebe8952c1906553b438874c5261e17..3225eeaa78f185c71533360906841283c6aac2f0 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2018-08-20 Aditya Keerthi <akeerthi@apple.com> >+ >+ [iOS] Add support for the inputmode attribute >+ https://bugs.webkit.org/show_bug.cgi?id=183621 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added test to verify behavior when getting and setting the inputmode attribute. >+ >+ * fast/forms/inputmode-attribute-expected.txt: Added. >+ * fast/forms/inputmode-attribute.html: Added. >+ > 2018-08-20 Rob Buis <rbuis@igalia.com> > > Throw an exception if window.open() gets passed a URL that cannot be parsed >diff --git a/LayoutTests/fast/forms/inputmode-attribute-expected.txt b/LayoutTests/fast/forms/inputmode-attribute-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..ff2daef1dd5fdd89008e773c1f811cdcf1920f38 >--- /dev/null >+++ b/LayoutTests/fast/forms/inputmode-attribute-expected.txt >@@ -0,0 +1,44 @@ >+Test inputmode attribute >+ >+ >+Missing value default: >+PASS input.inputMode is "" >+PASS input.getAttribute("inputmode") is null >+ >+Invalid value default: >+PASS input.inputMode = "foobar"; input.inputMode is "" >+PASS input.getAttribute("inputmode") is "foobar" >+PASS input.setAttribute("inputmode", "baz"); input.inputMode is "" >+ >+Valid values: >+PASS input.inputMode = "text"; input.inputMode is "text" >+PASS input.getAttribute("inputmode") is "text" >+PASS input.setAttribute("inputmode", "text"); input.inputMode is "text" >+PASS input.inputMode = "tel"; input.inputMode is "tel" >+PASS input.getAttribute("inputmode") is "tel" >+PASS input.setAttribute("inputmode", "tel"); input.inputMode is "tel" >+PASS input.inputMode = "url"; input.inputMode is "url" >+PASS input.getAttribute("inputmode") is "url" >+PASS input.setAttribute("inputmode", "url"); input.inputMode is "url" >+PASS input.inputMode = "email"; input.inputMode is "email" >+PASS input.getAttribute("inputmode") is "email" >+PASS input.setAttribute("inputmode", "email"); input.inputMode is "email" >+PASS input.inputMode = "numeric"; input.inputMode is "numeric" >+PASS input.getAttribute("inputmode") is "numeric" >+PASS input.setAttribute("inputmode", "numeric"); input.inputMode is "numeric" >+PASS input.inputMode = "decimal"; input.inputMode is "decimal" >+PASS input.getAttribute("inputmode") is "decimal" >+PASS input.setAttribute("inputmode", "decimal"); input.inputMode is "decimal" >+PASS input.inputMode = "search"; input.inputMode is "search" >+PASS input.getAttribute("inputmode") is "search" >+PASS input.setAttribute("inputmode", "search"); input.inputMode is "search" >+ >+Valid case-insensitive values: >+PASS input.inputMode = "tExt"; input.inputMode is "text" >+PASS input.getAttribute("inputmode") is "tExt" >+PASS input.setAttribute("inputmode", "tExt"); input.inputMode is "text" >+ >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/forms/inputmode-attribute.html b/LayoutTests/fast/forms/inputmode-attribute.html >new file mode 100644 >index 0000000000000000000000000000000000000000..3dd408dcfe0fdfd7303becc58e1f751e3c0cd56a >--- /dev/null >+++ b/LayoutTests/fast/forms/inputmode-attribute.html >@@ -0,0 +1,53 @@ >+<!DOCTYPE html> >+<html> >+<body> >+<script src="../../resources/js-test-pre.js"></script> >+<p>Test inputmode attribute</p> >+<input id="input"> >+<div id=console></div> >+<script> >+debug('Missing value default:'); >+shouldBe('input.inputMode', '""'); >+shouldBeNull('input.getAttribute("inputmode")'); >+ >+debug(''); >+debug('Invalid value default:'); >+shouldBe('input.inputMode = "foobar"; input.inputMode', '""'); >+shouldBe('input.getAttribute("inputmode")', '"foobar"'); >+shouldBe('input.setAttribute("inputmode", "baz"); input.inputMode', '""'); >+ >+debug(''); >+debug('Valid values:'); >+shouldBe('input.inputMode = "text"; input.inputMode', '"text"'); >+shouldBe('input.getAttribute("inputmode")', '"text"'); >+shouldBe('input.setAttribute("inputmode", "text"); input.inputMode', '"text"'); >+shouldBe('input.inputMode = "tel"; input.inputMode', '"tel"'); >+shouldBe('input.getAttribute("inputmode")', '"tel"'); >+shouldBe('input.setAttribute("inputmode", "tel"); input.inputMode', '"tel"'); >+shouldBe('input.inputMode = "url"; input.inputMode', '"url"'); >+shouldBe('input.getAttribute("inputmode")', '"url"'); >+shouldBe('input.setAttribute("inputmode", "url"); input.inputMode', '"url"'); >+shouldBe('input.inputMode = "email"; input.inputMode', '"email"'); >+shouldBe('input.getAttribute("inputmode")', '"email"'); >+shouldBe('input.setAttribute("inputmode", "email"); input.inputMode', '"email"'); >+shouldBe('input.inputMode = "numeric"; input.inputMode', '"numeric"'); >+shouldBe('input.getAttribute("inputmode")', '"numeric"'); >+shouldBe('input.setAttribute("inputmode", "numeric"); input.inputMode', '"numeric"'); >+shouldBe('input.inputMode = "decimal"; input.inputMode', '"decimal"'); >+shouldBe('input.getAttribute("inputmode")', '"decimal"'); >+shouldBe('input.setAttribute("inputmode", "decimal"); input.inputMode', '"decimal"'); >+shouldBe('input.inputMode = "search"; input.inputMode', '"search"'); >+shouldBe('input.getAttribute("inputmode")', '"search"'); >+shouldBe('input.setAttribute("inputmode", "search"); input.inputMode', '"search"'); >+ >+debug(''); >+debug('Valid case-insensitive values:'); >+shouldBe('input.inputMode = "tExt"; input.inputMode', '"text"'); >+shouldBe('input.getAttribute("inputmode")', '"tExt"'); >+shouldBe('input.setAttribute("inputmode", "tExt"); input.inputMode', '"text"'); >+ >+debug(''); >+</script> >+<script src="../../resources/js-test-post.js"></script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 183621
:
347340
|
347396
|
347413
|
347504
|
347720
|
347812
|
347820