Changeset 251686 in webkit


Ignore:
Timestamp:
Oct 28, 2019 4:56:14 PM (4 years ago)
Author:
Wenson Hsieh
Message:

Add bindings support for the enterkeyhint HTML attribute
https://bugs.webkit.org/show_bug.cgi?id=203440

Reviewed by Ryosuke Niwa.

Source/WebCore:

Work towards support for the enterkeyhint attribute. This patch introduces the new attribute to HTMLElement's
IDL; see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-enterkeyhint-attribute
for more information. This version of the spec was last updated October 25, 2019 (at time of writing).

Test: fast/forms/enterkeyhint-attribute-values.html

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • html/EnterKeyHint.cpp: Added.

Add a new helper file that declares a new EnterKeyHint enum type, as well as helper functions to map between
attribute values and EnterKeyHint values.

(WebCore::enterKeyHintForAttributeValue):
(WebCore::attributeValueForEnterKeyHint):

  • html/EnterKeyHint.h: Added.
  • html/HTMLAttributeNames.in:
  • html/HTMLElement.cpp:

(WebCore::HTMLElement::canonicalEnterKeyHint const):

Returns the canonical EnterKeyHint enum value, by inspecting the "enterkeyhint" attribute value.

(WebCore::HTMLElement::enterKeyHint const):
(WebCore::HTMLElement::setEnterKeyHint):

Implement enterKeyHint. Since enterkeyhint is a reflected HTML attribute with enumerated values, the setter sets
the attribute value and the getter returns the "canonicalized" attribute value.

  • html/HTMLElement.h:
  • html/HTMLElement.idl:

Add the new attribute. Note that this isn't marked as [Reflect] in IDL, since doing so would generate incorrect
bindings code. This is because we don't support reflection for enumerated attributes in our bindings generator
yet, so for now, we just match HTMLInputElement.type and HTMLElement.inputMode.

  • page/Settings.yaml:

Add a new runtime switch to guard the enterkeyhint attribute.

Source/WebKit:

Add a new runtime switch for the enterkeyhint attribute, and enable it by default on macOS and iOS.

  • Shared/WebPreferences.yaml:
  • Shared/WebPreferencesDefaultValues.h:

LayoutTests:

  • fast/forms/enterkeyhint-attribute-values-expected.txt: Added.
  • fast/forms/enterkeyhint-attribute-values.html: Added.

Add a new layout test to exercise the new attribute (including case sensitivity, the default value, unknown
values, all known value types, and different types of elements).

  • platform/ios-wk2/TestExpectations:
  • platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt:
  • platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/reflection-misc-expected.txt: Added.
  • platform/ios-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt:
  • platform/mac-wk2/TestExpectations:
  • platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt:
  • platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/reflection-misc-expected.txt: Added.
  • platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt:

Add some new baselines for some existing layout tests.

Location:
trunk
Files:
7 added
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r251685 r251686  
     12019-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add bindings support for the enterkeyhint HTML attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=203440
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        * fast/forms/enterkeyhint-attribute-values-expected.txt: Added.
     9        * fast/forms/enterkeyhint-attribute-values.html: Added.
     10
     11        Add a new layout test to exercise the new attribute (including case sensitivity, the default value, unknown
     12        values, all known value types, and different types of elements).
     13
     14        * platform/ios-wk2/TestExpectations:
     15        * platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt:
     16        * platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/reflection-misc-expected.txt: Added.
     17        * platform/ios-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt:
     18        * platform/mac-wk2/TestExpectations:
     19        * platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt:
     20        * platform/mac-wk2/imported/w3c/web-platform-tests/html/dom/reflection-misc-expected.txt: Added.
     21        * platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt:
     22
     23        Add some new baselines for some existing layout tests.
     24
    1252019-10-28  Truitt Savell  <tsavell@apple.com>
    226
  • trunk/LayoutTests/TestExpectations

    r251677 r251686  
    7070# WebKit2 only.
    7171printing/printing-events.html [ Skip ]
     72fast/forms/enterkeyhint-attribute-values.html [ Skip ]
    7273
    7374http/tests/security/xss-DENIED-xsl-external-entity-no-logging.xml [ Skip ]
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt

    r251630 r251686  
    193193FAIL HTMLElement interface: attribute onpaste assert_own_property: expected property "onpaste" missing
    194194PASS HTMLElement interface: attribute contentEditable
    195 FAIL HTMLElement interface: attribute enterKeyHint assert_true: The prototype object must have a property "enterKeyHint" expected true got false
     195PASS HTMLElement interface: attribute enterKeyHint
    196196PASS HTMLElement interface: attribute isContentEditable
    197197PASS HTMLElement interface: attribute inputMode
     
    283283PASS HTMLElement interface: document.createElement("noscript") must inherit property "onpaste" with the proper type
    284284PASS HTMLElement interface: document.createElement("noscript") must inherit property "contentEditable" with the proper type
    285 FAIL HTMLElement interface: document.createElement("noscript") must inherit property "enterKeyHint" with the proper type assert_inherits: property "enterKeyHint" not found in prototype chain
     285PASS HTMLElement interface: document.createElement("noscript") must inherit property "enterKeyHint" with the proper type
    286286PASS HTMLElement interface: document.createElement("noscript") must inherit property "isContentEditable" with the proper type
    287287PASS HTMLElement interface: document.createElement("noscript") must inherit property "inputMode" with the proper type
  • trunk/LayoutTests/platform/ios-wk2/TestExpectations

    r251609 r251686  
    2828accessibility/smart-invert.html [ Pass ]
    2929accessibility/smart-invert-reference.html [ Pass ]
     30fast/forms/enterkeyhint-attribute-values.html [ Pass ]
    3031fast/media/mq-inverted-colors-live-update.html [ Pass ]
    3132fast/media/mq-inverted-colors-live-update-in-subframes.html [ Pass ]
  • trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/html/dom/idlharness.https-expected.txt

    r251630 r251686  
    193193FAIL HTMLElement interface: attribute onpaste assert_own_property: expected property "onpaste" missing
    194194PASS HTMLElement interface: attribute contentEditable
    195 FAIL HTMLElement interface: attribute enterKeyHint assert_true: The prototype object must have a property "enterKeyHint" expected true got false
     195PASS HTMLElement interface: attribute enterKeyHint
    196196PASS HTMLElement interface: attribute isContentEditable
    197197PASS HTMLElement interface: attribute inputMode
     
    283283PASS HTMLElement interface: document.createElement("noscript") must inherit property "onpaste" with the proper type
    284284PASS HTMLElement interface: document.createElement("noscript") must inherit property "contentEditable" with the proper type
    285 FAIL HTMLElement interface: document.createElement("noscript") must inherit property "enterKeyHint" with the proper type assert_inherits: property "enterKeyHint" not found in prototype chain
     285PASS HTMLElement interface: document.createElement("noscript") must inherit property "enterKeyHint" with the proper type
    286286PASS HTMLElement interface: document.createElement("noscript") must inherit property "isContentEditable" with the proper type
    287287PASS HTMLElement interface: document.createElement("noscript") must inherit property "inputMode" with the proper type
  • trunk/LayoutTests/platform/ios-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt

    r244582 r251686  
    5353PASS a["webkitdropzone"] is
    5454PASS a["inputMode"] is
     55PASS a["enterKeyHint"] is
    5556PASS a["style"] is [object CSSStyleDeclaration]
    5657PASS a["attributeStyleMap"] is [object StylePropertyMap]
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r251598 r251686  
    2222fast/events/autoscroll-when-zoomed.html [ Pass ]
    2323fast/events/autoscroll-main-document.html [ Pass ]
     24
     25fast/forms/enterkeyhint-attribute-values.html [ Pass ]
    2426
    2527accessibility/smart-invert.html [ Pass ]
  • trunk/LayoutTests/platform/mac-wk2/js/dom/dom-static-property-for-in-iteration-expected.txt

    r250584 r251686  
    5353PASS a["webkitdropzone"] is
    5454PASS a["inputMode"] is
     55PASS a["enterKeyHint"] is
    5556PASS a["style"] is [object CSSStyleDeclaration]
    5657PASS a["attributeStyleMap"] is [object StylePropertyMap]
  • trunk/Source/WebCore/ChangeLog

    r251683 r251686  
     12019-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add bindings support for the enterkeyhint HTML attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=203440
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Work towards support for the enterkeyhint attribute. This patch introduces the new attribute to HTMLElement's
     9        IDL; see https://html.spec.whatwg.org/multipage/interaction.html#input-modalities:-the-enterkeyhint-attribute
     10        for more information. This version of the spec was last updated October 25, 2019 (at time of writing).
     11
     12        Test: fast/forms/enterkeyhint-attribute-values.html
     13
     14        * Sources.txt:
     15        * WebCore.xcodeproj/project.pbxproj:
     16        * html/EnterKeyHint.cpp: Added.
     17
     18        Add a new helper file that declares a new EnterKeyHint enum type, as well as helper functions to map between
     19        attribute values and EnterKeyHint values.
     20
     21        (WebCore::enterKeyHintForAttributeValue):
     22        (WebCore::attributeValueForEnterKeyHint):
     23        * html/EnterKeyHint.h: Added.
     24        * html/HTMLAttributeNames.in:
     25        * html/HTMLElement.cpp:
     26        (WebCore::HTMLElement::canonicalEnterKeyHint const):
     27
     28        Returns the canonical EnterKeyHint enum value, by inspecting the "enterkeyhint" attribute value.
     29
     30        (WebCore::HTMLElement::enterKeyHint const):
     31        (WebCore::HTMLElement::setEnterKeyHint):
     32
     33        Implement enterKeyHint. Since enterkeyhint is a reflected HTML attribute with enumerated values, the setter sets
     34        the attribute value and the getter returns the "canonicalized" attribute value.
     35
     36        * html/HTMLElement.h:
     37        * html/HTMLElement.idl:
     38
     39        Add the new attribute. Note that this isn't marked as [Reflect] in IDL, since doing so would generate incorrect
     40        bindings code. This is because we don't support reflection for enumerated attributes in our bindings generator
     41        yet, so for now, we just match `HTMLInputElement.type` and `HTMLElement.inputMode`.
     42
     43        * page/Settings.yaml:
     44
     45        Add a new runtime switch to guard the enterkeyhint attribute.
     46
    1472019-10-28  Chris Dumez  <cdumez@apple.com>
    248
  • trunk/Source/WebCore/Sources.txt

    r251637 r251686  
    11111111html/DateTimeLocalInputType.cpp
    11121112html/EmailInputType.cpp
     1113html/EnterKeyHint.cpp
    11131114html/FTPDirectoryDocument.cpp
    11141115html/FileListCreator.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r251655 r251686  
    48914891                F3ABFE0C130E9DA000E7F7D1 /* InstrumentingAgents.h in Headers */ = {isa = PBXBuildFile; fileRef = F3ABFE0B130E9DA000E7F7D1 /* InstrumentingAgents.h */; };
    48924892                F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; };
     4893                F403E7872363B58C00044550 /* EnterKeyHint.h in Headers */ = {isa = PBXBuildFile; fileRef = F403E7852363B58C00044550 /* EnterKeyHint.h */; settings = {ATTRIBUTES = (Private, ); }; };
    48934894                F433E9031DBBDBA200EF0D14 /* StaticPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F433E9021DBBDBA200EF0D14 /* StaticPasteboard.h */; settings = {ATTRIBUTES = (Private, ); }; };
    48944895                F440E77A233D94D70063F9AB /* NavigatorClipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = F440E76F233D94D30063F9AB /* NavigatorClipboard.h */; };
     
    1526115262                F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; };
    1526215263                F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; };
     15264                F403E7852363B58C00044550 /* EnterKeyHint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnterKeyHint.h; sourceTree = "<group>"; };
     15265                F403E7862363B58C00044550 /* EnterKeyHint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = EnterKeyHint.cpp; sourceTree = "<group>"; };
    1526315266                F42CEB54214031EE002DCA72 /* FontAttributeChangesCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FontAttributeChangesCocoa.mm; sourceTree = "<group>"; };
    1526415267                F433E9021DBBDBA200EF0D14 /* StaticPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticPasteboard.h; sourceTree = "<group>"; };
     
    2159821601                                F55B3D871251F12D003EF269 /* EmailInputType.cpp */,
    2159921602                                F55B3D881251F12D003EF269 /* EmailInputType.h */,
     21603                                F403E7862363B58C00044550 /* EnterKeyHint.cpp */,
     21604                                F403E7852363B58C00044550 /* EnterKeyHint.h */,
    2160021605                                41A0829B22932EF4008426E0 /* FeaturePolicy.cpp */,
    2160121606                                41A0829922932EF4008426E0 /* FeaturePolicy.h */,
     
    2951329518                                414DEDE71F9FE91E0047C40D /* EmptyFrameLoaderClient.h in Headers */,
    2951429519                                515BE1901D54F5FB00DD7C68 /* EmptyGamepadProvider.h in Headers */,
     29520                                F403E7872363B58C00044550 /* EnterKeyHint.h in Headers */,
    2951529521                                1D2F8E042344751600993B68 /* EnterPictureInPictureEvent.h in Headers */,
    2951629522                                FD31609312B026F700C1A359 /* EqualPowerPanner.h in Headers */,
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r250712 r251686  
    122122enctype
    123123end
     124enterkeyhint
    124125event
    125126expanded
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r248784 r251686  
    3535#include "DocumentFragment.h"
    3636#include "ElementAncestorIterator.h"
     37#include "EnterKeyHint.h"
    3738#include "Event.h"
    3839#include "EventListener.h"
     
    11201121}
    11211122
     1123EnterKeyHint HTMLElement::canonicalEnterKeyHint() const
     1124{
     1125    return enterKeyHintForAttributeValue(attributeWithoutSynchronization(enterkeyhintAttr));
     1126}
     1127
     1128String HTMLElement::enterKeyHint() const
     1129{
     1130    return attributeValueForEnterKeyHint(canonicalEnterKeyHint());
     1131}
     1132
     1133void HTMLElement::setEnterKeyHint(const String& value)
     1134{
     1135    setAttributeWithoutSynchronization(enterkeyhintAttr, value);
     1136}
     1137
    11221138} // namespace WebCore
    11231139
  • trunk/Source/WebCore/html/HTMLElement.h

    r249194 r251686  
    3737class HTMLCollection;
    3838class HTMLFormElement;
     39
     40enum class EnterKeyHint : uint8_t;
    3941
    4042class HTMLElement : public StyledElement {
     
    115117    void setInputMode(const AtomString& value);
    116118
     119    WEBCORE_EXPORT EnterKeyHint canonicalEnterKeyHint() const;
     120    String enterKeyHint() const;
     121    void setEnterKeyHint(const String& value);
     122
    117123protected:
    118124    HTMLElement(const QualifiedName& tagName, Document&, ConstructionType);
  • trunk/Source/WebCore/html/HTMLElement.idl

    r249212 r251686  
    6666
    6767    attribute DOMString inputMode;
     68    [EnabledBySetting=EnterKeyHint] attribute DOMString enterKeyHint;
    6869};
    6970
  • trunk/Source/WebCore/page/Settings.yaml

    r251467 r251686  
    876876  initial: false
    877877
     878enterKeyHintEnabled:
     879  initial: false
     880
    878881# Deprecated
    879882
  • trunk/Source/WebKit/ChangeLog

    r251676 r251686  
     12019-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Add bindings support for the enterkeyhint HTML attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=203440
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Add a new runtime switch for the enterkeyhint attribute, and enable it by default on macOS and iOS.
     9
     10        * Shared/WebPreferences.yaml:
     11        * Shared/WebPreferencesDefaultValues.h:
     12
    1132019-10-28  Alex Christensen  <achristensen@webkit.org>
    214
  • trunk/Source/WebKit/Shared/WebPreferences.yaml

    r251656 r251686  
    17141714  condition: PLATFORM(IOS_FAMILY)
    17151715
     1716EnterKeyHintEnabled:
     1717  type: bool
     1718  defaultValue: DEFAULT_ENTER_KEY_HINT_ENABLED
     1719  humanReadableName: "Enter Key Hint"
     1720  humanReadableDescription: "Enable the enterKeyHint HTML attribute"
     1721  category: internal
     1722
    17161723ReferrerPolicyAttributeEnabled:
    17171724  type: bool
  • trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h

    r251656 r251686  
    301301#endif
    302302
     303#if PLATFORM(COCOA)
     304#define DEFAULT_ENTER_KEY_HINT_ENABLED true
     305#else
     306#define DEFAULT_ENTER_KEY_HINT_ENABLED false
     307#endif
     308
    303309namespace WebKit {
    304310
Note: See TracChangeset for help on using the changeset viewer.