Add credit card autofill button
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2018 20:08:43 +0000 (20:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Oct 2018 20:08:43 +0000 (20:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191051
<rdar://problem/45657011>

Patch by Zach Li <zacharyli323@gmail.com> on 2018-10-31
Reviewed by Wenson Hsieh.

Source/WebCore:

Test: fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* css/html.css:
(input::-webkit-credit-card-auto-fill-button):
Add credit card autofill button.
(input::-webkit-credit-card-auto-fill-button:hover):
(input::-webkit-credit-card-auto-fill-button:active):
* html/HTMLTextFormControlElement.h:
* html/TextFieldInputType.cpp:
(WebCore::autoFillButtonTypeToAccessibilityLabel):
(WebCore::autoFillButtonTypeToAutoFillButtonText):
(WebCore::autoFillButtonTypeToAutoFillButtonPseudoClassName):
(WebCore::isAutoFillButtonTypeChanged):
* platform/LocalizedStrings.cpp:
(WebCore::AXAutoFillCreditCardLabel):
* platform/LocalizedStrings.h:
* testing/Internals.cpp:
(WebCore::toAutoFillButtonType):
(WebCore::toInternalsAutoFillButtonType):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
(toAutoFillButtonType):
(toWKAutoFillButtonType):
* WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h:
Introduce a new button type for credit card autofill.
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
(toAutoFillButtonType):
(toWKAutoFillButtonType):
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:

LayoutTests:

* fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt: Added.
* fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html: Added.
* fast/forms/auto-fill-button/last-auto-fill-button-type-expected.txt:
* fast/forms/auto-fill-button/last-auto-fill-button-type.html:
* platform/ios-simulator/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt: Added.
* platform/mac/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.png: Added.
* platform/win/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237647 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/last-auto-fill-button-type-expected.txt
LayoutTests/fast/forms/auto-fill-button/last-auto-fill-button-type.html
LayoutTests/platform/ios-simulator/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.png [new file with mode: 0644]
LayoutTests/platform/win/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/css/html.css
Source/WebCore/html/HTMLTextFormControlElement.h
Source/WebCore/html/TextFieldInputType.cpp
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm
Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h

index 68a0d5b..963e4a1 100644 (file)
@@ -1,3 +1,19 @@
+2018-10-31  Zach Li  <zacharyli323@gmail.com>
+
+        Add credit card autofill button
+        https://bugs.webkit.org/show_bug.cgi?id=191051
+        <rdar://problem/45657011>
+
+        Reviewed by Wenson Hsieh.
+
+        * fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt: Added.
+        * fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html: Added.
+        * fast/forms/auto-fill-button/last-auto-fill-button-type-expected.txt:
+        * fast/forms/auto-fill-button/last-auto-fill-button-type.html:
+        * platform/ios-simulator/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt: Added.
+        * platform/mac/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.png: Added.
+        * platform/win/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt: Added.
+
 2018-10-31  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Audit: show metadata for results
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt b/LayoutTests/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt
new file mode 100644 (file)
index 0000000..cb5da7b
--- /dev/null
@@ -0,0 +1,44 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x81
+  RenderBlock {HTML} at (0,0) size 800x81
+    RenderBody {BODY} at (8,16) size 784x57
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 582x18
+          text run at (0,0) width 196: "This tests that the Credit Card "
+          text run at (195,0) width 387: "AutoFill button renders. It can only be tested in the test tool."
+      RenderBlock {DIV} at (0,34) size 784x23
+        RenderTextControl {INPUT} at (2,2) size 146x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,3) size 140x13
+            RenderBlock {DIV} at (0,0) size 113x13
+        RenderText {#text} at (149,2) size 5x18
+          text run at (149,2) width 5: " "
+        RenderTextControl {INPUT} at (155,2) size 147x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,3) size 140x13
+            RenderBlock {DIV} at (0,0) size 113x13
+        RenderText {#text} at (303,2) size 5x18
+          text run at (303,2) width 5: " "
+        RenderTextControl {INPUT} at (309,2) size 147x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,3) size 140x13
+            RenderBlock {DIV} at (0,0) size 113x13
+        RenderText {#text} at (457,2) size 5x18
+          text run at (457,2) width 5: " "
+        RenderTextControl {INPUT} at (463,2) size 147x19 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (3,3) size 140x13
+            RenderBlock {DIV} at (0,0) size 113x13
+layer at (13,55) size 113x13
+  RenderBlock {DIV} at (0,0) size 113x13
+layer at (167,55) size 113x13
+  RenderBlock {DIV} at (0,0) size 113x13
+layer at (321,55) size 113x13
+  RenderBlock {DIV} at (0,0) size 113x13
+layer at (475,55) size 113x13
+  RenderBlock {DIV} at (0,0) size 113x13
+layer at (129,56) size 22x12
+  RenderBlock {DIV} at (115,0) size 23x13 [bgcolor=#000000]
+layer at (283,56) size 22x12
+  RenderBlock {DIV} at (115,0) size 23x13 [bgcolor=#000000]
+layer at (437,56) size 22x12
+  RenderBlock {DIV} at (115,0) size 23x13 [bgcolor=#000000]
+layer at (591,56) size 22x12
+  RenderBlock {DIV} at (115,0) size 23x13 [bgcolor=#000000]
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html b/LayoutTests/fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html
new file mode 100644 (file)
index 0000000..482fd8f
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the Credit Card  AutoFill button renders. It can only be tested in the test tool.</p>
+<div id="container">
+    <input type="text">
+    <input type="text" name="cc_number">
+    <input type="text" name="cc_holder">
+</div>
+<script>
+
+if (window.internals) {
+    var inputs = document.querySelectorAll("input");
+    for (var i = 0; i < inputs.length; ++i)
+        window.internals.setShowAutoFillButton(inputs[i], "CreditCard");
+
+    var dynamicInput = document.createElement("input");
+    window.internals.setShowAutoFillButton(dynamicInput, "CreditCard");
+    document.querySelector("#container").appendChild(dynamicInput);
+}
+</script>
+</body>
+</html>
index 7839caa..d6ecfa3 100644 (file)
@@ -16,9 +16,12 @@ PASS internals.lastAutoFillButtonType(inputElement) is "Contacts"
 internals.setShowAutoFillButton(inputElement, 'Credentials')
 PASS internals.autoFillButtonType(inputElement) is "Credentials"
 PASS internals.lastAutoFillButtonType(inputElement) is "StrongPassword"
+internals.setShowAutoFillButton(inputElement, 'CreditCard')
+PASS internals.autoFillButtonType(inputElement) is "CreditCard"
+PASS internals.lastAutoFillButtonType(inputElement) is "Credentials"
 internals.setShowAutoFillButton(inputElement, 'None')
 PASS internals.autoFillButtonType(inputElement) is "None"
-PASS internals.lastAutoFillButtonType(inputElement) is "Credentials"
+PASS internals.lastAutoFillButtonType(inputElement) is "CreditCard"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 26a7550..6407818 100644 (file)
@@ -25,9 +25,12 @@ else {
     evalAndLog("internals.setShowAutoFillButton(inputElement, 'Credentials')");
     shouldBeEqualToString("internals.autoFillButtonType(inputElement)", "Credentials");
     shouldBeEqualToString("internals.lastAutoFillButtonType(inputElement)", "StrongPassword");
+    evalAndLog("internals.setShowAutoFillButton(inputElement, 'CreditCard')");
+    shouldBeEqualToString("internals.autoFillButtonType(inputElement)", "CreditCard");
+    shouldBeEqualToString("internals.lastAutoFillButtonType(inputElement)", "Credentials");
     evalAndLog("internals.setShowAutoFillButton(inputElement, 'None')");
     shouldBeEqualToString("internals.autoFillButtonType(inputElement)", "None");
-    shouldBeEqualToString("internals.lastAutoFillButtonType(inputElement)", "Credentials");
+    shouldBeEqualToString("internals.lastAutoFillButtonType(inputElement)", "CreditCard");
 }
 </script>
 </body>
diff --git a/LayoutTests/platform/ios-simulator/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt b/LayoutTests/platform/ios-simulator/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt
new file mode 100644 (file)
index 0000000..d95d1e1
--- /dev/null
@@ -0,0 +1,44 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x85
+  RenderBlock {HTML} at (0,0) size 800x85
+    RenderBody {BODY} at (8,16) size 784x61
+      RenderBlock {P} at (0,0) size 784x20
+        RenderText {#text} at (0,0) size 582x19
+          text run at (0,0) width 196: "This tests that the Credit Card "
+          text run at (195,0) width 387: "AutoFill button renders. It can only be tested in the test tool."
+      RenderBlock {DIV} at (0,36) size 784x25
+        RenderTextControl {INPUT} at (2,2) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 96x14
+        RenderText {#text} at (139,1) size 5x19
+          text run at (139,1) width 5: " "
+        RenderTextControl {INPUT} at (145,2) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 96x14
+        RenderText {#text} at (282,1) size 5x19
+          text run at (282,1) width 5: " "
+        RenderTextControl {INPUT} at (288,2) size 137x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 96x14
+        RenderText {#text} at (426,1) size 5x19
+          text run at (426,1) width 5: " "
+        RenderTextControl {INPUT} at (432,2) size 136x22 [bgcolor=#FFFFFF] [border: (1px solid #4C4C4C)]
+          RenderFlexibleBox {DIV} at (6,3) size 123x15
+            RenderBlock {DIV} at (0,0) size 96x14
+layer at (17,57) size 95x14
+  RenderBlock {DIV} at (0,0) size 96x14
+layer at (160,57) size 95x14
+  RenderBlock {DIV} at (0,0) size 96x14
+layer at (303,57) size 95x14
+  RenderBlock {DIV} at (0,0) size 96x14
+layer at (447,57) size 95x14
+  RenderBlock {DIV} at (0,0) size 96x14
+layer at (115,58) size 22x12
+  RenderBlock {DIV} at (98,1) size 23x12 [bgcolor=#000000]
+layer at (258,58) size 22x12
+  RenderBlock {DIV} at (98,1) size 23x12 [bgcolor=#000000]
+layer at (402,58) size 22x12
+  RenderBlock {DIV} at (98,1) size 23x12 [bgcolor=#000000]
+layer at (545,58) size 22x12
+  RenderBlock {DIV} at (98,1) size 23x12 [bgcolor=#000000]
diff --git a/LayoutTests/platform/mac/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.png b/LayoutTests/platform/mac/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.png
new file mode 100644 (file)
index 0000000..b4c07c9
Binary files /dev/null and b/LayoutTests/platform/mac/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.png differ
diff --git a/LayoutTests/platform/win/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt b/LayoutTests/platform/win/fast/forms/auto-fill-button/input-credit-card-auto-fill-button-expected.txt
new file mode 100644 (file)
index 0000000..f76b8bb
--- /dev/null
@@ -0,0 +1,44 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x83
+  RenderBlock {HTML} at (0,0) size 800x83
+    RenderBody {BODY} at (8,16) size 784x59
+      RenderBlock {P} at (0,0) size 784x18
+        RenderText {#text} at (0,0) size 568x18
+          text run at (0,0) width 191: "This tests that the Credit Card "
+          text run at (191,0) width 377: "AutoFill button renders. It can only be tested in the test tool."
+      RenderBlock {DIV} at (0,34) size 784x25
+        RenderTextControl {INPUT} at (2,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (2,3) size 145x15
+            RenderBlock {DIV} at (0,0) size 118x15
+        RenderText {#text} at (153,3) size 4x18
+          text run at (153,3) width 4: " "
+        RenderTextControl {INPUT} at (159,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (2,3) size 145x15
+            RenderBlock {DIV} at (0,0) size 118x15
+        RenderText {#text} at (310,3) size 4x18
+          text run at (310,3) width 4: " "
+        RenderTextControl {INPUT} at (316,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (2,3) size 145x15
+            RenderBlock {DIV} at (0,0) size 118x15
+        RenderText {#text} at (467,3) size 4x18
+          text run at (467,3) width 4: " "
+        RenderTextControl {INPUT} at (473,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
+          RenderFlexibleBox {DIV} at (2,3) size 145x15
+            RenderBlock {DIV} at (0,0) size 118x15
+layer at (12,55) size 118x15
+  RenderBlock {DIV} at (0,0) size 118x15
+layer at (169,55) size 118x15
+  RenderBlock {DIV} at (0,0) size 118x15
+layer at (326,55) size 118x15
+  RenderBlock {DIV} at (0,0) size 118x15
+layer at (483,55) size 118x15
+  RenderBlock {DIV} at (0,0) size 118x15
+layer at (133,57) size 22x12
+  RenderBlock {DIV} at (121,1) size 22x13 [bgcolor=#000000]
+layer at (290,57) size 22x12
+  RenderBlock {DIV} at (121,1) size 22x13 [bgcolor=#000000]
+layer at (447,57) size 22x12
+  RenderBlock {DIV} at (121,1) size 22x13 [bgcolor=#000000]
+layer at (604,57) size 22x12
+  RenderBlock {DIV} at (121,1) size 22x13 [bgcolor=#000000]
index 72f396c..7004bd6 100644 (file)
@@ -1,3 +1,35 @@
+2018-10-31  Zach Li  <zacharyli323@gmail.com>
+
+        Add credit card autofill button
+        https://bugs.webkit.org/show_bug.cgi?id=191051
+        <rdar://problem/45657011>
+
+        Reviewed by Wenson Hsieh.
+
+        Test: fast/forms/auto-fill-button/input-credit-card-auto-fill-button.html
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * css/html.css:
+        (input::-webkit-credit-card-auto-fill-button):
+        Add credit card autofill button.
+        (input::-webkit-credit-card-auto-fill-button:hover):
+        (input::-webkit-credit-card-auto-fill-button:active):
+        * html/HTMLTextFormControlElement.h:
+        * html/TextFieldInputType.cpp:
+        (WebCore::autoFillButtonTypeToAccessibilityLabel):
+        (WebCore::autoFillButtonTypeToAutoFillButtonText):
+        (WebCore::autoFillButtonTypeToAutoFillButtonPseudoClassName):
+        (WebCore::isAutoFillButtonTypeChanged):
+        * platform/LocalizedStrings.cpp:
+        (WebCore::AXAutoFillCreditCardLabel):
+        * platform/LocalizedStrings.h:
+        * testing/Internals.cpp:
+        (WebCore::toAutoFillButtonType):
+        (WebCore::toInternalsAutoFillButtonType):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2018-10-31  Eric Carlson  <eric.carlson@apple.com>
 
         [MediaStream] Don't reveal device IDs until the user has granted permission to capture
index bdd6d6e..7afeeea 100644 (file)
@@ -3110,6 +3110,8 @@ IGNORE_WARNINGS_END
             return @"contacts";
         case AutoFillButtonType::StrongPassword:
             return @"strong password";
+        case AutoFillButtonType::CreditCard:
+            return @"credit card";
         }
     }
     
index 1aeed6b..d013206 100644 (file)
@@ -602,6 +602,26 @@ input::-webkit-contacts-auto-fill-button:active {
     background-color: rgb(0, 60, 219);
 }
 
+input::-webkit-credit-card-auto-fill-button {
+    -webkit-mask-image: -webkit-image-set(url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAAYCAYAAAC1Ft6mAAAAAXNSR0IArs4c6QAAAYlJREFUWAntmD1OA0EMhQMFBBACCRqq5F4cANHDAZAoaBB00NAiDkSXggvQIAp+JH7eVziYkZddKTOzKPAka2yPx/aLN5NVBoM5xKo4XUmeJB8VhDrUo24RkLwGkbQGdbNjQRn5xIbZM7cnfFbISnvYH49gQjwKfYH6WbGYNdsvSPZPqNIQblTnRbLXsR5xXDKcK3Zlj5R7M5GtpJ7MEK/y2jW/H0Z8Odm3WM5NDXPmWiETweeP9vEdSHxcEykm4+MOOewdOfVZCNHXkevtXfouTgfsN4n1fGx75si9zkqI/k5cwzRvpFIyxE2Rm4jl4/uSYlkO22ftgpTUpQ75yXwjQ0JfoLbehRAxpw19nkUJapPw9aJ+Ih9vFBcSfxY7fNPwQbX1qPkmH80zEa7mc0lIBickDGMpD2ZoHUruJDvOh7ouuZWMMBy2pU+c3aaGTbUd+mk/ffXZSIL59eUTSW+sR/mWJGsSj3tv9KGnE6rdQ5EJMYU+UKQuj9x1H2xK1p27P0l6GlCZsp/oV3aRfWEA1gAAAABJRU5ErkJggg==") 2x);
+    -webkit-mask-size: 22px 12px;
+    width: 22px;
+    height: 12px;
+    margin-left: 3px;
+    margin-right: 2px;
+    background-color: black;
+    flex: none;
+    -webkit-user-select: none;
+}
+
+input::-webkit-credit-card-auto-fill-button:hover {
+    background-color: rgb(0, 122, 255);
+}
+
+input::-webkit-credit-card-auto-fill-button:active {
+    background-color: rgb(0, 60, 219);
+}
+
 input::-webkit-caps-lock-indicator {
     -webkit-appearance: caps-lock-indicator;
     content: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17"><path fill="black" fill-opacity="0.4" d="M12.5 0.5A 4 4 0 0 1 16.5 4.5L 16.5 12.5A 4 4 0 0 1 12.5 16.5L 4.5 16.5A 4 4 0 0 1 0.5 12.5L 0.5 4.5A 4 4 0 0 1 4.5 0.5L 12.5 0.5M 8.5 2L 4 7L 6.25 7L 6.25 10.25L 10.75 10.25L 10.75 7L 13 7L 8.5 2M 10.75 12L 6.25 12L 6.25 14.25L 10.75 14.25L 10.75 12"/></svg>');
index d262314..b1e35cb 100644 (file)
@@ -33,7 +33,7 @@ class RenderTextControl;
 class TextControlInnerTextElement;
 class VisiblePosition;
 
-enum class AutoFillButtonType : uint8_t { None, Credentials, Contacts, StrongPassword };
+enum class AutoFillButtonType : uint8_t { None, Credentials, Contacts, StrongPassword, CreditCard };
 enum TextFieldSelectionDirection { SelectionHasNoDirection, SelectionHasForwardDirection, SelectionHasBackwardDirection };
 enum TextFieldEventBehavior { DispatchNoEvent, DispatchChangeEvent, DispatchInputAndChangeEvent };
 
index f9a9b88..ff770a6 100644 (file)
@@ -480,6 +480,8 @@ static String autoFillButtonTypeToAccessibilityLabel(AutoFillButtonType autoFill
         return AXAutoFillCredentialsLabel();
     case AutoFillButtonType::StrongPassword:
         return AXAutoFillStrongPasswordLabel();
+    case AutoFillButtonType::CreditCard:
+        return AXAutoFillCreditCardLabel();
     case AutoFillButtonType::None:
         ASSERT_NOT_REACHED();
         return { };
@@ -493,6 +495,7 @@ static String autoFillButtonTypeToAutoFillButtonText(AutoFillButtonType autoFill
     switch (autoFillButtonType) {
     case AutoFillButtonType::Contacts:
     case AutoFillButtonType::Credentials:
+    case AutoFillButtonType::CreditCard:
         return emptyString();
     case AutoFillButtonType::StrongPassword:
         return autoFillStrongPasswordLabel();
@@ -513,6 +516,8 @@ static AtomicString autoFillButtonTypeToAutoFillButtonPseudoClassName(AutoFillBu
         return { "-webkit-credentials-auto-fill-button", AtomicString::ConstructFromLiteral };
     case AutoFillButtonType::StrongPassword:
         return { "-webkit-strong-password-auto-fill-button", AtomicString::ConstructFromLiteral };
+    case AutoFillButtonType::CreditCard:
+        return { "-webkit-credit-card-auto-fill-button", AtomicString::ConstructFromLiteral };
     case AutoFillButtonType::None:
         ASSERT_NOT_REACHED();
         return emptyAtom();
@@ -529,6 +534,8 @@ static bool isAutoFillButtonTypeChanged(const AtomicString& attribute, AutoFillB
         return true;
     if (attribute == "-webkit-strong-password-auto-fill-button" && autoFillButtonType != AutoFillButtonType::StrongPassword)
         return true;
+    if (attribute == "-webkit-credit-card-auto-fill-button" && autoFillButtonType != AutoFillButtonType::CreditCard)
+        return true;
     return false;
 }
 
index 7782826..bb83bfa 100644 (file)
@@ -625,6 +625,11 @@ String AXAutoFillStrongPasswordLabel()
     return WEB_UI_STRING("strong password auto fill", "Label for the strong password auto fill button inside a text field.");
 }
 
+String AXAutoFillCreditCardLabel()
+{
+    return WEB_UI_STRING("credit card auto fill", "Label for the credit card auto fill button inside a text field.");
+}
+
 String autoFillStrongPasswordLabel()
 {
     return WEB_UI_STRING("Strong Password", "Label for strong password.");
index 5335082..43d02d0 100644 (file)
@@ -216,6 +216,7 @@ namespace WebCore {
     String AXAutoFillCredentialsLabel();
     String AXAutoFillContactsLabel();
     String AXAutoFillStrongPasswordLabel();
+    String AXAutoFillCreditCardLabel();
     String autoFillStrongPasswordLabel();
 
     String missingPluginText();
index 8efaf2a..c2829c2 100644 (file)
@@ -1778,6 +1778,8 @@ static AutoFillButtonType toAutoFillButtonType(Internals::AutoFillButtonType typ
         return AutoFillButtonType::Contacts;
     case Internals::AutoFillButtonType::StrongPassword:
         return AutoFillButtonType::StrongPassword;
+    case Internals::AutoFillButtonType::CreditCard:
+        return AutoFillButtonType::CreditCard;
     }
     ASSERT_NOT_REACHED();
     return AutoFillButtonType::None;
@@ -1794,6 +1796,8 @@ static Internals::AutoFillButtonType toInternalsAutoFillButtonType(AutoFillButto
         return Internals::AutoFillButtonType::Contacts;
     case AutoFillButtonType::StrongPassword:
         return Internals::AutoFillButtonType::StrongPassword;
+    case AutoFillButtonType::CreditCard:
+        return Internals::AutoFillButtonType::CreditCard;
     }
     ASSERT_NOT_REACHED();
     return Internals::AutoFillButtonType::None;
index 01d4dd6..e5276a5 100644 (file)
@@ -254,7 +254,7 @@ public:
     bool elementShouldAutoComplete(HTMLInputElement&);
     void setEditingValue(HTMLInputElement&, const String&);
     void setAutofilled(HTMLInputElement&, bool enabled);
-    enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword };
+    enum class AutoFillButtonType { None, Contacts, Credentials, StrongPassword, CreditCard };
     void setShowAutoFillButton(HTMLInputElement&, AutoFillButtonType);
     AutoFillButtonType autoFillButtonType(const HTMLInputElement&);
     AutoFillButtonType lastAutoFillButtonType(const HTMLInputElement&);
index 773042e..04cc51d 100644 (file)
@@ -62,7 +62,8 @@ enum AutoFillButtonType {
     "None",
     "Contacts",
     "Credentials",
-    "StrongPassword"
+    "StrongPassword",
+    "CreditCard"
 };
 
 enum UserInterfaceLayoutDirection {
index f6df416..9b2065e 100644 (file)
@@ -1,3 +1,21 @@
+2018-10-31  Zach Li  <zacharyli323@gmail.com>
+
+        Add credit card autofill button
+        https://bugs.webkit.org/show_bug.cgi?id=191051
+        <rdar://problem/45657011>
+
+        Reviewed by Wenson Hsieh.
+
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandle.mm:
+        (toAutoFillButtonType):
+        (toWKAutoFillButtonType):
+        * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInNodeHandlePrivate.h:
+        Introduce a new button type for credit card autofill.
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+        (toAutoFillButtonType):
+        (toWKAutoFillButtonType):
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
+
 2018-10-31  Chris Dumez  <cdumez@apple.com>
 
         [PSON] When process-swapping for a POST request the HTTP body gets dropped
index 1a3fa2d..a57e577 100644 (file)
@@ -127,6 +127,8 @@ static WebCore::AutoFillButtonType toAutoFillButtonType(_WKAutoFillButtonType au
         return WebCore::AutoFillButtonType::Credentials;
     case _WKAutoFillButtonTypeStrongPassword:
         return WebCore::AutoFillButtonType::StrongPassword;
+    case _WKAutoFillButtonTypeCreditCard:
+        return WebCore::AutoFillButtonType::CreditCard;
     }
     ASSERT_NOT_REACHED();
     return WebCore::AutoFillButtonType::None;
@@ -143,6 +145,8 @@ static _WKAutoFillButtonType toWKAutoFillButtonType(WebCore::AutoFillButtonType
         return _WKAutoFillButtonTypeCredentials;
     case WebCore::AutoFillButtonType::StrongPassword:
         return _WKAutoFillButtonTypeStrongPassword;
+    case WebCore::AutoFillButtonType::CreditCard:
+        return _WKAutoFillButtonTypeCreditCard;
     }
     ASSERT_NOT_REACHED();
     return _WKAutoFillButtonTypeNone;
index a9dce0d..5e0d562 100644 (file)
@@ -32,6 +32,7 @@ typedef NS_ENUM(NSInteger, _WKAutoFillButtonType) {
     _WKAutoFillButtonTypeCredentials,
     _WKAutoFillButtonTypeContacts,
     _WKAutoFillButtonTypeStrongPassword,
+    _WKAutoFillButtonTypeCreditCard WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)),
 } WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
 
 @interface WKWebProcessPlugInNodeHandle (WKPrivate)
index cded804..4c7dbb4 100644 (file)
@@ -48,6 +48,8 @@ static WebCore::AutoFillButtonType toAutoFillButtonType(WKAutoFillButtonType wkA
         return WebCore::AutoFillButtonType::Credentials;
     case kWKAutoFillButtonTypeStrongPassword:
         return WebCore::AutoFillButtonType::StrongPassword;
+    case kWKAutoFillButtonTypeCreditCard:
+        return WebCore::AutoFillButtonType::CreditCard;
     }
     ASSERT_NOT_REACHED();
     return WebCore::AutoFillButtonType::None;
@@ -64,6 +66,8 @@ static WKAutoFillButtonType toWKAutoFillButtonType(WebCore::AutoFillButtonType a
         return kWKAutoFillButtonTypeCredentials;
     case WebCore::AutoFillButtonType::StrongPassword:
         return kWKAutoFillButtonTypeStrongPassword;
+    case WebCore::AutoFillButtonType::CreditCard:
+        return kWKAutoFillButtonTypeCreditCard;
     }
     ASSERT_NOT_REACHED();
     return kWKAutoFillButtonTypeNone;
index bcef9f2..07929b6 100644 (file)
@@ -40,6 +40,7 @@ enum {
     kWKAutoFillButtonTypeCredentials,
     kWKAutoFillButtonTypeContacts,
     kWKAutoFillButtonTypeStrongPassword,
+    kWKAutoFillButtonTypeCreditCard,
 };
 typedef uint8_t WKAutoFillButtonType;