| Differences between
and this patch
- a/Source/WebCore/ChangeLog +30 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2018-08-17  Aditya Keerthi  <akeerthi@apple.com>
2
3
        [iOS] Add support for the inputmode attribute
4
        https://bugs.webkit.org/show_bug.cgi?id=183621
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Added the inputmode attribute to the HTMLInputElement and HTMLTextAreaElement IDL
9
        files. The possible values for the attribute are specified in InputModeNames.
10
11
        Test: fast/forms/inputmode-attribute.html
12
13
        * WebCore.xcodeproj/project.pbxproj:
14
        * html/HTMLAttributeNames.in:
15
        * html/HTMLInputElement.idl:
16
        * html/HTMLTextAreaElement.idl:
17
        * html/HTMLTextFormControlElement.cpp:
18
        (WebCore::HTMLTextFormControlElement::inputMode const):
19
        (WebCore::HTMLTextFormControlElement::setInputMode):
20
        * html/HTMLTextFormControlElement.h:
21
        * html/InputModeNames.cpp: Added.
22
        (WebCore::InputModeNames::text):
23
        (WebCore::InputModeNames::tel):
24
        (WebCore::InputModeNames::url):
25
        (WebCore::InputModeNames::email):
26
        (WebCore::InputModeNames::numeric):
27
        (WebCore::InputModeNames::decimal):
28
        (WebCore::InputModeNames::search):
29
        * html/InputModeNames.h: Added.
30
1
2018-08-16  Ryosuke Niwa  <rniwa@webkit.org>
31
2018-08-16  Ryosuke Niwa  <rniwa@webkit.org>
2
32
3
        Replace canBubble and cancelable booleans in Event by enum classes
33
        Replace canBubble and cancelable booleans in Event by enum classes
- a/Source/WebKit/ChangeLog +33 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2018-08-17  Aditya Keerthi  <akeerthi@apple.com>
2
3
        [iOS] Add support for the inputmode attribute
4
        https://bugs.webkit.org/show_bug.cgi?id=183621
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        The inputmode attribute specifies which input mechanism would be most helpful for
9
        users entering content in textfield inputs and textareas. This patch adds support
10
        for seven values: text, tel, url, email, numeric, decimal and search.
11
12
        On iOS, we can specify UIKeyboardTypes that best match the supplied inputmode.
13
        - text: UIKeyboardTypeDefault
14
        - tel: UIKeyboardTypePhonePad
15
        - url: UIKeyboardTypeURL
16
        - email: UIKeyboardTypeEmailAddress
17
        - numeric: UIKeyboardTypeNumberPad
18
        - decimal: UIKeyboardTypeDecimalPad
19
        - search: UIKeyboardTypeWebSearch
20
21
        In the case that the inputmode attribute is not specified, we fall back to using
22
        our existing heuristic to determine what kind of keyboard to show for textfields.
23
24
        * Shared/AssistedNodeInformation.cpp:
25
        (WebKit::AssistedNodeInformation::encode const):
26
        (WebKit::AssistedNodeInformation::decode):
27
        * Shared/AssistedNodeInformation.h: Added inputMode field.
28
        * UIProcess/ios/WKContentViewInteraction.mm:
29
        (-[WKContentView textInputTraits]):
30
        * WebProcess/WebPage/ios/WebPageIOS.mm:
31
        (WebKit::inputModeForElement):
32
        (WebKit::WebPage::getAssistedNodeInformation):
33
1
2018-08-16  Ryosuke Niwa  <rniwa@webkit.org>
34
2018-08-16  Ryosuke Niwa  <rniwa@webkit.org>
2
35
3
        Replace canBubble and cancelable booleans in Event by enum classes
36
        Replace canBubble and cancelable booleans in Event by enum classes
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj +8 lines
Lines 4790-4795 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
4790
		E517670320B88C1400D41167 /* DataListSuggestionInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = E517670220B88C1400D41167 /* DataListSuggestionInformation.h */; settings = {ATTRIBUTES = (Private, ); }; };
4790
		E517670320B88C1400D41167 /* DataListSuggestionInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = E517670220B88C1400D41167 /* DataListSuggestionInformation.h */; settings = {ATTRIBUTES = (Private, ); }; };
4791
		E52CF54D20A268AC00DADA27 /* DataListSuggestionsClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF54C20A268AC00DADA27 /* DataListSuggestionsClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
4791
		E52CF54D20A268AC00DADA27 /* DataListSuggestionsClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF54C20A268AC00DADA27 /* DataListSuggestionsClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
4792
		E52CF54F20A35A2800DADA27 /* DataListSuggestionPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF54E20A35A2800DADA27 /* DataListSuggestionPicker.h */; settings = {ATTRIBUTES = (Private, ); }; };
4792
		E52CF54F20A35A2800DADA27 /* DataListSuggestionPicker.h in Headers */ = {isa = PBXBuildFile; fileRef = E52CF54E20A35A2800DADA27 /* DataListSuggestionPicker.h */; settings = {ATTRIBUTES = (Private, ); }; };
4793
		E52EFDF42112875A00AD282A /* InputModeNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E52EFDF22112875A00AD282A /* InputModeNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
4794
		E52EFDF52112875A00AD282A /* InputModeNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E52EFDF32112875A00AD282A /* InputModeNames.cpp */; };
4793
		E58B45BA20AD07DD00991025 /* DataListButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E58B45B820AD07DD00991025 /* DataListButtonElement.h */; };
4795
		E58B45BA20AD07DD00991025 /* DataListButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = E58B45B820AD07DD00991025 /* DataListButtonElement.h */; };
4794
		E58B45BB20AD07DD00991025 /* DataListButtonElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E58B45B920AD07DD00991025 /* DataListButtonElement.cpp */; };
4796
		E58B45BB20AD07DD00991025 /* DataListButtonElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E58B45B920AD07DD00991025 /* DataListButtonElement.cpp */; };
4795
		E5BA7D63151437CA00FE1E3F /* LengthFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
4797
		E5BA7D63151437CA00FE1E3F /* LengthFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E5BA7D62151437CA00FE1E3F /* LengthFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 14523-14528 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
14523
		E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
14525
		E526AF3E1727F8F200E41781 /* Performance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Performance.cpp; sourceTree = "<group>"; };
14524
		E52CF54C20A268AC00DADA27 /* DataListSuggestionsClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionsClient.h; sourceTree = "<group>"; };
14526
		E52CF54C20A268AC00DADA27 /* DataListSuggestionsClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionsClient.h; sourceTree = "<group>"; };
14525
		E52CF54E20A35A2800DADA27 /* DataListSuggestionPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionPicker.h; sourceTree = "<group>"; };
14527
		E52CF54E20A35A2800DADA27 /* DataListSuggestionPicker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListSuggestionPicker.h; sourceTree = "<group>"; };
14528
		E52EFDF22112875A00AD282A /* InputModeNames.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InputModeNames.h; sourceTree = "<group>"; };
14529
		E52EFDF32112875A00AD282A /* InputModeNames.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = InputModeNames.cpp; sourceTree = "<group>"; };
14526
		E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; };
14530
		E55F4979151B888000BB67DB /* LengthFunctions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LengthFunctions.cpp; sourceTree = "<group>"; };
14527
		E58B45B820AD07DD00991025 /* DataListButtonElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListButtonElement.h; sourceTree = "<group>"; };
14531
		E58B45B820AD07DD00991025 /* DataListButtonElement.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DataListButtonElement.h; sourceTree = "<group>"; };
14528
		E58B45B920AD07DD00991025 /* DataListButtonElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DataListButtonElement.cpp; sourceTree = "<group>"; };
14532
		E58B45B920AD07DD00991025 /* DataListButtonElement.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DataListButtonElement.cpp; sourceTree = "<group>"; };
Lines 20804-20809 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
20804
				97205AB21239291000B17380 /* ImageDocument.h */,
20808
				97205AB21239291000B17380 /* ImageDocument.h */,
20805
				F55B3D8D1251F12D003EF269 /* ImageInputType.cpp */,
20809
				F55B3D8D1251F12D003EF269 /* ImageInputType.cpp */,
20806
				F55B3D8E1251F12D003EF269 /* ImageInputType.h */,
20810
				F55B3D8E1251F12D003EF269 /* ImageInputType.h */,
20811
				E52EFDF32112875A00AD282A /* InputModeNames.cpp */,
20812
				E52EFDF22112875A00AD282A /* InputModeNames.h */,
20807
				37E3524A12450C5200BAF5D9 /* InputType.cpp */,
20813
				37E3524A12450C5200BAF5D9 /* InputType.cpp */,
20808
				37E3524C12450C6600BAF5D9 /* InputType.h */,
20814
				37E3524C12450C6600BAF5D9 /* InputType.h */,
20809
				C348612115FDE21E007A1CC9 /* InputTypeNames.cpp */,
20815
				C348612115FDE21E007A1CC9 /* InputTypeNames.cpp */,
Lines 28434-28439 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
28434
				1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */,
28440
				1C010701192594DF008A4201 /* InlineTextBoxStyle.h in Headers */,
28435
				510A58E51BAA40B100C19282 /* InProcessIDBServer.h in Headers */,
28441
				510A58E51BAA40B100C19282 /* InProcessIDBServer.h in Headers */,
28436
				2EB767571DA19BDF003E23B5 /* InputEvent.h in Headers */,
28442
				2EB767571DA19BDF003E23B5 /* InputEvent.h in Headers */,
28443
				E52EFDF42112875A00AD282A /* InputModeNames.h in Headers */,
28437
				37E3524D12450C6600BAF5D9 /* InputType.h in Headers */,
28444
				37E3524D12450C6600BAF5D9 /* InputType.h in Headers */,
28438
				C348612415FDE21E007A1CC9 /* InputTypeNames.h in Headers */,
28445
				C348612415FDE21E007A1CC9 /* InputTypeNames.h in Headers */,
28439
				93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */,
28446
				93309DEA099E64920056E581 /* InsertIntoTextNodeCommand.h in Headers */,
Lines 31568-31573 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
31568
				07367DE0172CA68200D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.mm in Sources */,
31575
				07367DE0172CA68200D861B9 /* InbandTextTrackPrivateLegacyAVFObjC.mm in Sources */,
31569
				BE16C59417CFE17200852C04 /* InbandWebVTTTextTrack.cpp in Sources */,
31576
				BE16C59417CFE17200852C04 /* InbandWebVTTTextTrack.cpp in Sources */,
31570
				CD063F821E23FA8900812BE3 /* InitDataRegistry.cpp in Sources */,
31577
				CD063F821E23FA8900812BE3 /* InitDataRegistry.cpp in Sources */,
31578
				E52EFDF52112875A00AD282A /* InputModeNames.cpp in Sources */,
31571
				538EC93E1F99BF5A004D22A8 /* JSQuickTimePluginReplacement.cpp in Sources */,
31579
				538EC93E1F99BF5A004D22A8 /* JSQuickTimePluginReplacement.cpp in Sources */,
31572
				935C477009AC4D7300A6AAB4 /* KeyEventMac.mm in Sources */,
31580
				935C477009AC4D7300A6AAB4 /* KeyEventMac.mm in Sources */,
31573
				CDA98E0B1603CD6000FEA3B1 /* LegacyCDM.cpp in Sources */,
31581
				CDA98E0B1603CD6000FEA3B1 /* LegacyCDM.cpp in Sources */,
- a/Source/WebCore/html/HTMLAttributeNames.in +1 lines
Lines 144-149 http_equiv a/Source/WebCore/html/HTMLAttributeNames.in_sec1
144
id
144
id
145
incremental
145
incremental
146
indeterminate
146
indeterminate
147
inputmode
147
integrity
148
integrity
148
is
149
is
149
ismap
150
ismap
- a/Source/WebCore/html/HTMLInputElement.idl +1 lines
Lines 42-47 a/Source/WebCore/html/HTMLInputElement.idl_sec1
42
    [Reflect] attribute DOMString formTarget;
42
    [Reflect] attribute DOMString formTarget;
43
    attribute unsigned long height;
43
    attribute unsigned long height;
44
    attribute boolean indeterminate;
44
    attribute boolean indeterminate;
45
    attribute DOMString inputMode;
45
    [Conditional=DATALIST_ELEMENT] readonly attribute HTMLElement list;
46
    [Conditional=DATALIST_ELEMENT] readonly attribute HTMLElement list;
46
    [Reflect] attribute DOMString max;
47
    [Reflect] attribute DOMString max;
47
    attribute long minLength;
48
    attribute long minLength;
- a/Source/WebCore/html/HTMLTextAreaElement.idl +1 lines
Lines 59-62 interface HTMLTextAreaElement : HTMLElement { a/Source/WebCore/html/HTMLTextAreaElement.idl_sec1
59
    void setSelectionRange(optional long start = 0, optional long end = 0, optional DOMString direction);
59
    void setSelectionRange(optional long start = 0, optional long end = 0, optional DOMString direction);
60
60
61
    attribute DOMString autocomplete;
61
    attribute DOMString autocomplete;
62
    attribute DOMString inputMode;
62
};
63
};
- a/Source/WebCore/html/HTMLTextFormControlElement.cpp +27 lines
Lines 39-44 a/Source/WebCore/html/HTMLTextFormControlElement.cpp_sec1
39
#include "HTMLInputElement.h"
39
#include "HTMLInputElement.h"
40
#include "HTMLNames.h"
40
#include "HTMLNames.h"
41
#include "HTMLParserIdioms.h"
41
#include "HTMLParserIdioms.h"
42
#include "InputModeNames.h"
42
#include "LayoutDisallowedScope.h"
43
#include "LayoutDisallowedScope.h"
43
#include "Logging.h"
44
#include "Logging.h"
44
#include "NodeTraversal.h"
45
#include "NodeTraversal.h"
Lines 674-679 void HTMLTextFormControlElement::showPlaceholderIfNecessary() a/Source/WebCore/html/HTMLTextFormControlElement.cpp_sec2
674
}
675
}
675
#endif
676
#endif
676
677
678
String HTMLTextFormControlElement::inputMode() const
679
{
680
    const AtomicString& inputMode = attributeWithoutSynchronization(inputmodeAttr);
681
    if (equalIgnoringASCIICase(inputMode, InputModeNames::text()))
682
        return InputModeNames::text();
683
    if (equalIgnoringASCIICase(inputMode, InputModeNames::tel()))
684
        return InputModeNames::tel();
685
    if (equalIgnoringASCIICase(inputMode, InputModeNames::url()))
686
        return InputModeNames::url();
687
    if (equalIgnoringASCIICase(inputMode, InputModeNames::email()))
688
        return InputModeNames::email();
689
    if (equalIgnoringASCIICase(inputMode, InputModeNames::numeric()))
690
        return InputModeNames::numeric();
691
    if (equalIgnoringASCIICase(inputMode, InputModeNames::decimal()))
692
        return InputModeNames::decimal();
693
    if (equalIgnoringASCIICase(inputMode, InputModeNames::search()))
694
        return InputModeNames::search();
695
696
    return emptyString();
697
}
698
699
void HTMLTextFormControlElement::setInputMode(const String& value)
700
{
701
    setAttributeWithoutSynchronization(inputmodeAttr, value);
702
}
703
677
static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& breakOffset)
704
static void getNextSoftBreak(RootInlineBox*& line, Node*& breakNode, unsigned& breakOffset)
678
{
705
{
679
    RootInlineBox* next;
706
    RootInlineBox* next;
- a/Source/WebCore/html/HTMLTextFormControlElement.h +3 lines
Lines 98-103 public: a/Source/WebCore/html/HTMLTextFormControlElement.h_sec1
98
    WEBCORE_EXPORT void showPlaceholderIfNecessary();
98
    WEBCORE_EXPORT void showPlaceholderIfNecessary();
99
#endif
99
#endif
100
100
101
    WEBCORE_EXPORT String inputMode() const;
102
    void setInputMode(const String&);
103
101
protected:
104
protected:
102
    HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*);
105
    HTMLTextFormControlElement(const QualifiedName&, Document&, HTMLFormElement*);
103
    bool isPlaceholderEmpty() const;
106
    bool isPlaceholderEmpty() const;
- a/Source/WebCore/html/InputModeNames.cpp +79 lines
Line 0 a/Source/WebCore/html/InputModeNames.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "InputModeNames.h"
28
29
#include <wtf/NeverDestroyed.h>
30
31
namespace WebCore {
32
33
namespace InputModeNames {
34
35
const AtomicString& text()
36
{
37
    static NeverDestroyed<AtomicString> mode("text", AtomicString::ConstructFromLiteral);
38
    return mode;
39
}
40
41
const AtomicString& tel()
42
{
43
    static NeverDestroyed<AtomicString> mode("tel", AtomicString::ConstructFromLiteral);
44
    return mode;
45
}
46
47
const AtomicString& url()
48
{
49
    static NeverDestroyed<AtomicString> mode("url", AtomicString::ConstructFromLiteral);
50
    return mode;
51
}
52
53
const AtomicString& email()
54
{
55
    static NeverDestroyed<AtomicString> mode("email", AtomicString::ConstructFromLiteral);
56
    return mode;
57
}
58
59
const AtomicString& numeric()
60
{
61
    static NeverDestroyed<AtomicString> mode("numeric", AtomicString::ConstructFromLiteral);
62
    return mode;
63
}
64
65
const AtomicString& decimal()
66
{
67
    static NeverDestroyed<AtomicString> mode("decimal", AtomicString::ConstructFromLiteral);
68
    return mode;
69
}
70
71
const AtomicString& search()
72
{
73
    static NeverDestroyed<AtomicString> mode("search", AtomicString::ConstructFromLiteral);
74
    return mode;
75
}
76
77
} // namespace WebCore::InputModeNames
78
79
} // namespace WebCore
- a/Source/WebCore/html/InputModeNames.h +44 lines
Line 0 a/Source/WebCore/html/InputModeNames.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23
 * THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include <wtf/text/AtomicString.h>
29
30
namespace WebCore {
31
32
namespace InputModeNames {
33
34
WEBCORE_EXPORT const AtomicString& text();
35
WEBCORE_EXPORT const AtomicString& tel();
36
WEBCORE_EXPORT const AtomicString& url();
37
WEBCORE_EXPORT const AtomicString& email();
38
WEBCORE_EXPORT const AtomicString& numeric();
39
WEBCORE_EXPORT const AtomicString& decimal();
40
WEBCORE_EXPORT const AtomicString& search();
41
42
}
43
44
} // namespace WebCore
- a/Source/WebKit/Shared/AssistedNodeInformation.cpp +4 lines
Lines 77-82 void AssistedNodeInformation::encode(IPC::Encoder& encoder) const a/Source/WebKit/Shared/AssistedNodeInformation.cpp_sec1
77
    encoder << isRTL;
77
    encoder << isRTL;
78
    encoder.encodeEnum(autocapitalizeType);
78
    encoder.encodeEnum(autocapitalizeType);
79
    encoder.encodeEnum(elementType);
79
    encoder.encodeEnum(elementType);
80
    encoder.encodeEnum(inputMode);
80
    encoder << formAction;
81
    encoder << formAction;
81
    encoder << selectOptions;
82
    encoder << selectOptions;
82
    encoder << selectedIndex;
83
    encoder << selectedIndex;
Lines 142-147 bool AssistedNodeInformation::decode(IPC::Decoder& decoder, AssistedNodeInformat a/Source/WebKit/Shared/AssistedNodeInformation.cpp_sec2
142
    if (!decoder.decodeEnum(result.elementType))
143
    if (!decoder.decodeEnum(result.elementType))
143
        return false;
144
        return false;
144
145
146
    if (!decoder.decodeEnum(result.inputMode))
147
        return false;
148
145
    if (!decoder.decode(result.formAction))
149
    if (!decoder.decode(result.formAction))
146
        return false;
150
        return false;
147
151
- a/Source/WebKit/Shared/AssistedNodeInformation.h +12 lines
Lines 58-63 enum class InputType { a/Source/WebKit/Shared/AssistedNodeInformation.h_sec1
58
#endif
58
#endif
59
};
59
};
60
60
61
enum class InputMode {
62
    Auto,
63
    Text,
64
    Telephone,
65
    Url,
66
    Email,
67
    Numeric,
68
    Decimal,
69
    Search
70
};
71
61
#if PLATFORM(IOS)
72
#if PLATFORM(IOS)
62
struct OptionItem {
73
struct OptionItem {
63
    OptionItem() { }
74
    OptionItem() { }
Lines 109-114 struct AssistedNodeInformation { a/Source/WebKit/Shared/AssistedNodeInformation.h_sec2
109
    bool insideFixedPosition { false };
120
    bool insideFixedPosition { false };
110
    AutocapitalizeType autocapitalizeType { AutocapitalizeTypeDefault };
121
    AutocapitalizeType autocapitalizeType { AutocapitalizeTypeDefault };
111
    InputType elementType { InputType::None };
122
    InputType elementType { InputType::None };
123
    InputMode inputMode { InputMode::Auto };
112
    String formAction;
124
    String formAction;
113
    Vector<OptionItem> selectOptions;
125
    Vector<OptionItem> selectOptions;
114
    int selectedIndex { -1 };
126
    int selectedIndex { -1 };
- a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm -10 / +35 lines
Lines 3533-3556 static NSString *contentTypeFromFieldName(WebCore::AutofillFieldName fieldName) a/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm_sec1
3533
        [_traits setAutocorrectionType:_assistedNodeInformation.isAutocorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo];
3533
        [_traits setAutocorrectionType:_assistedNodeInformation.isAutocorrect ? UITextAutocorrectionTypeYes : UITextAutocorrectionTypeNo];
3534
    }
3534
    }
3535
3535
3536
    switch (_assistedNodeInformation.elementType) {
3536
    switch (_assistedNodeInformation.inputMode) {
3537
    case InputType::Phone:
3537
    case InputMode::Auto:
3538
        switch (_assistedNodeInformation.elementType) {
3539
        case InputType::Phone:
3540
            [_traits setKeyboardType:UIKeyboardTypePhonePad];
3541
            break;
3542
        case InputType::URL:
3543
            [_traits setKeyboardType:UIKeyboardTypeURL];
3544
            break;
3545
        case InputType::Email:
3546
            [_traits setKeyboardType:UIKeyboardTypeEmailAddress];
3547
            break;
3548
        case InputType::Number:
3549
            [_traits setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
3550
            break;
3551
        case InputType::NumberPad:
3552
            [_traits setKeyboardType:UIKeyboardTypeNumberPad];
3553
            break;
3554
        default:
3555
            [_traits setKeyboardType:UIKeyboardTypeDefault];
3556
        }
3557
        break;
3558
    case InputMode::Text:
3559
        [_traits setKeyboardType:UIKeyboardTypeDefault];
3560
        break;
3561
    case InputMode::Telephone:
3538
        [_traits setKeyboardType:UIKeyboardTypePhonePad];
3562
        [_traits setKeyboardType:UIKeyboardTypePhonePad];
3539
        break;
3563
        break;
3540
    case InputType::URL:
3564
    case InputMode::Url:
3541
        [_traits setKeyboardType:UIKeyboardTypeURL];
3565
        [_traits setKeyboardType:UIKeyboardTypeURL];
3542
        break;
3566
        break;
3543
    case InputType::Email:
3567
    case InputMode::Email:
3544
        [_traits setKeyboardType:UIKeyboardTypeEmailAddress];
3568
        [_traits setKeyboardType:UIKeyboardTypeEmailAddress];
3545
        break;
3569
        break;
3546
    case InputType::Number:
3570
    case InputMode::Numeric:
3547
        [_traits setKeyboardType:UIKeyboardTypeNumbersAndPunctuation];
3548
        break;
3549
    case InputType::NumberPad:
3550
        [_traits setKeyboardType:UIKeyboardTypeNumberPad];
3571
        [_traits setKeyboardType:UIKeyboardTypeNumberPad];
3551
        break;
3572
        break;
3552
    default:
3573
    case InputMode::Decimal:
3553
        [_traits setKeyboardType:UIKeyboardTypeDefault];
3574
        [_traits setKeyboardType:UIKeyboardTypeDecimalPad];
3575
        break;
3576
    case InputMode::Search:
3577
        [_traits setKeyboardType:UIKeyboardTypeWebSearch];
3578
        break;
3554
    }
3579
    }
3555
3580
3556
    [_traits setTextContentType:contentTypeFromFieldName(_assistedNodeInformation.autofillFieldName)];
3581
    [_traits setTextContentType:contentTypeFromFieldName(_assistedNodeInformation.autofillFieldName)];
- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm +25 lines
Lines 84-91 a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm_sec1
84
#import <WebCore/HTMLParserIdioms.h>
84
#import <WebCore/HTMLParserIdioms.h>
85
#import <WebCore/HTMLSelectElement.h>
85
#import <WebCore/HTMLSelectElement.h>
86
#import <WebCore/HTMLTextAreaElement.h>
86
#import <WebCore/HTMLTextAreaElement.h>
87
#import <WebCore/HTMLTextFormControlElement.h>
87
#import <WebCore/HistoryItem.h>
88
#import <WebCore/HistoryItem.h>
88
#import <WebCore/HitTestResult.h>
89
#import <WebCore/HitTestResult.h>
90
#import <WebCore/InputModeNames.h>
89
#import <WebCore/KeyboardEvent.h>
91
#import <WebCore/KeyboardEvent.h>
90
#import <WebCore/LibWebRTCProvider.h>
92
#import <WebCore/LibWebRTCProvider.h>
91
#import <WebCore/MediaSessionManagerIOS.h>
93
#import <WebCore/MediaSessionManagerIOS.h>
Lines 2297-2302 static IntRect elementRectInRootViewCoordinates(const Node& node, const Frame& f a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm_sec2
2297
    return view->contentsToRootView(renderer->absoluteBoundingBoxRect());
2299
    return view->contentsToRootView(renderer->absoluteBoundingBoxRect());
2298
}
2300
}
2299
2301
2302
static InputMode inputModeForElement(const Node& node)
2303
{
2304
    const AtomicString& inputMode = downcast<HTMLTextFormControlElement>(node).inputMode();
2305
    if (inputMode == InputModeNames::text())
2306
        return InputMode::Text;
2307
    if (inputMode == InputModeNames::tel())
2308
        return InputMode::Telephone;
2309
    if (inputMode == InputModeNames::url())
2310
        return InputMode::Url;
2311
    if (inputMode == InputModeNames::email())
2312
        return InputMode::Email;
2313
    if (inputMode == InputModeNames::numeric())
2314
        return InputMode::Numeric;
2315
    if (inputMode == InputModeNames::decimal())
2316
        return InputMode::Decimal;
2317
    if (inputMode == InputModeNames::search())
2318
        return InputMode::Search;
2319
2320
    return InputMode::Auto;
2321
}
2322
2300
void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
2323
void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information)
2301
{
2324
{
2302
    layoutIfNeeded();
2325
    layoutIfNeeded();
Lines 2402-2407 void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information) a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm_sec3
2402
        information.value = element.value();
2425
        information.value = element.value();
2403
        information.autofillFieldName = WebCore::toAutofillFieldName(element.autofillData().fieldName);
2426
        information.autofillFieldName = WebCore::toAutofillFieldName(element.autofillData().fieldName);
2404
        information.placeholder = element.attributeWithoutSynchronization(HTMLNames::placeholderAttr);
2427
        information.placeholder = element.attributeWithoutSynchronization(HTMLNames::placeholderAttr);
2428
        information.inputMode = inputModeForElement(element);
2405
    } else if (is<HTMLInputElement>(*m_assistedNode)) {
2429
    } else if (is<HTMLInputElement>(*m_assistedNode)) {
2406
        HTMLInputElement& element = downcast<HTMLInputElement>(*m_assistedNode);
2430
        HTMLInputElement& element = downcast<HTMLInputElement>(*m_assistedNode);
2407
        HTMLFormElement* form = element.form();
2431
        HTMLFormElement* form = element.form();
Lines 2455-2460 void WebPage::getAssistedNodeInformation(AssistedNodeInformation& information) a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm_sec4
2455
            information.elementType = InputType::Color;
2479
            information.elementType = InputType::Color;
2456
#endif
2480
#endif
2457
2481
2482
        information.inputMode = inputModeForElement(element);
2458
        information.isReadOnly = element.isReadOnly();
2483
        information.isReadOnly = element.isReadOnly();
2459
        information.value = element.value();
2484
        information.value = element.value();
2460
        information.valueAsNumber = element.valueAsNumber();
2485
        information.valueAsNumber = element.valueAsNumber();
- a/LayoutTests/ChangeLog +12 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2018-08-17  Aditya Keerthi  <akeerthi@apple.com>
2
3
        [iOS] Add support for the inputmode attribute
4
        https://bugs.webkit.org/show_bug.cgi?id=183621
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Added test to verify behavior when getting and setting the inputmode attribute.
9
10
        * fast/forms/inputmode-attribute-expected.txt: Added.
11
        * fast/forms/inputmode-attribute.html: Added.
12
1
2018-08-17  Devin Rousso  <drousso@apple.com>
13
2018-08-17  Devin Rousso  <drousso@apple.com>
2
14
3
        Marked inspector/dom-debugger/event-breakpoint-with-navigation.html as flaky.
15
        Marked inspector/dom-debugger/event-breakpoint-with-navigation.html as flaky.
- a/LayoutTests/fast/forms/inputmode-attribute-expected.txt +44 lines
Line 0 a/LayoutTests/fast/forms/inputmode-attribute-expected.txt_sec1
1
Test inputmode attribute
2
3
4
Missing value default:
5
PASS input.inputMode is ""
6
PASS input.getAttribute("inputmode") is null
7
8
Invalid value default:
9
PASS input.inputMode = "foobar"; input.inputMode is ""
10
PASS input.getAttribute("inputmode") is "foobar"
11
PASS input.setAttribute("inputmode", "baz"); input.inputMode is ""
12
13
Valid values:
14
PASS input.inputMode = "text"; input.inputMode is "text"
15
PASS input.getAttribute("inputmode") is "text"
16
PASS input.setAttribute("inputmode", "text"); input.inputMode is "text"
17
PASS input.inputMode = "tel"; input.inputMode is "tel"
18
PASS input.getAttribute("inputmode") is "tel"
19
PASS input.setAttribute("inputmode", "tel"); input.inputMode is "tel"
20
PASS input.inputMode = "url"; input.inputMode is "url"
21
PASS input.getAttribute("inputmode") is "url"
22
PASS input.setAttribute("inputmode", "url"); input.inputMode is "url"
23
PASS input.inputMode = "email"; input.inputMode is "email"
24
PASS input.getAttribute("inputmode") is "email"
25
PASS input.setAttribute("inputmode", "email"); input.inputMode is "email"
26
PASS input.inputMode = "numeric"; input.inputMode is "numeric"
27
PASS input.getAttribute("inputmode") is "numeric"
28
PASS input.setAttribute("inputmode", "numeric"); input.inputMode is "numeric"
29
PASS input.inputMode = "decimal"; input.inputMode is "decimal"
30
PASS input.getAttribute("inputmode") is "decimal"
31
PASS input.setAttribute("inputmode", "decimal"); input.inputMode is "decimal"
32
PASS input.inputMode = "search"; input.inputMode is "search"
33
PASS input.getAttribute("inputmode") is "search"
34
PASS input.setAttribute("inputmode", "search"); input.inputMode is "search"
35
36
Valid case-insensitive values:
37
PASS input.inputMode = "tExt"; input.inputMode is "text"
38
PASS input.getAttribute("inputmode") is "tExt"
39
PASS input.setAttribute("inputmode", "tExt"); input.inputMode is "text"
40
41
PASS successfullyParsed is true
42
43
TEST COMPLETE
44
- a/LayoutTests/fast/forms/inputmode-attribute.html +53 lines
Line 0 a/LayoutTests/fast/forms/inputmode-attribute.html_sec1
1
<!DOCTYPE html>
2
<html>
3
<body>
4
<script src="../../resources/js-test-pre.js"></script>
5
<p>Test inputmode attribute</p>
6
<input id="input">
7
<div id=console></div>
8
<script>
9
debug('Missing value default:');
10
shouldBe('input.inputMode', '""');
11
shouldBeNull('input.getAttribute("inputmode")');
12
13
debug('');
14
debug('Invalid value default:');
15
shouldBe('input.inputMode = "foobar"; input.inputMode', '""');
16
shouldBe('input.getAttribute("inputmode")', '"foobar"');
17
shouldBe('input.setAttribute("inputmode", "baz"); input.inputMode', '""');
18
19
debug('');
20
debug('Valid values:');
21
shouldBe('input.inputMode = "text"; input.inputMode', '"text"');
22
shouldBe('input.getAttribute("inputmode")', '"text"');
23
shouldBe('input.setAttribute("inputmode", "text"); input.inputMode', '"text"');
24
shouldBe('input.inputMode = "tel"; input.inputMode', '"tel"');
25
shouldBe('input.getAttribute("inputmode")', '"tel"');
26
shouldBe('input.setAttribute("inputmode", "tel"); input.inputMode', '"tel"');
27
shouldBe('input.inputMode = "url"; input.inputMode', '"url"');
28
shouldBe('input.getAttribute("inputmode")', '"url"');
29
shouldBe('input.setAttribute("inputmode", "url"); input.inputMode', '"url"');
30
shouldBe('input.inputMode = "email"; input.inputMode', '"email"');
31
shouldBe('input.getAttribute("inputmode")', '"email"');
32
shouldBe('input.setAttribute("inputmode", "email"); input.inputMode', '"email"');
33
shouldBe('input.inputMode = "numeric"; input.inputMode', '"numeric"');
34
shouldBe('input.getAttribute("inputmode")', '"numeric"');
35
shouldBe('input.setAttribute("inputmode", "numeric"); input.inputMode', '"numeric"');
36
shouldBe('input.inputMode = "decimal"; input.inputMode', '"decimal"');
37
shouldBe('input.getAttribute("inputmode")', '"decimal"');
38
shouldBe('input.setAttribute("inputmode", "decimal"); input.inputMode', '"decimal"');
39
shouldBe('input.inputMode = "search"; input.inputMode', '"search"');
40
shouldBe('input.getAttribute("inputmode")', '"search"');
41
shouldBe('input.setAttribute("inputmode", "search"); input.inputMode', '"search"');
42
43
debug('');
44
debug('Valid case-insensitive values:');
45
shouldBe('input.inputMode = "tExt"; input.inputMode', '"text"');
46
shouldBe('input.getAttribute("inputmode")', '"tExt"');
47
shouldBe('input.setAttribute("inputmode", "tExt"); input.inputMode', '"text"');
48
49
debug('');
50
</script>
51
<script src="../../resources/js-test-post.js"></script>
52
</body>
53
</html>

Return to Bug 183621