Title: [193551] branches/safari-601.1.46-branch

Diff

Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (193550 => 193551)


--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2015-12-06 05:56:23 UTC (rev 193551)
@@ -1,3 +1,18 @@
+2015-12-05  David Kilzer  <[email protected]>
+
+        Merge r191981. rdar://problem/23221177
+
+    2015-10-30  Jon Honeycutt  <[email protected]>
+
+        Implement support for the autocomplete attribute
+        https://bugs.webkit.org/show_bug.cgi?id=150731
+        rdar://problem/21078968
+
+        Reviewed by Brent Fulgham.
+
+        * fast/forms/autocomplete-tokens-expected.txt: Added.
+        * fast/forms/autocomplete-tokens.html: Added.
+
 2015-12-05  Matthew Hanson  <[email protected]>
 
         Merge r190868. rdar://problem/23769564

Added: branches/safari-601.1.46-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt (0 => 193551)


--- branches/safari-601.1.46-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt	                        (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt	2015-12-06 05:56:23 UTC (rev 193551)
@@ -0,0 +1,211 @@
+Tests for valid autocomplete tokens on input, select, and textarea elements.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Valid keywords:
+PASS input.autocomplete is "name"
+PASS input.autocomplete is "honorific-prefix"
+PASS input.autocomplete is "given-name"
+PASS input.autocomplete is "additional-name"
+PASS input.autocomplete is "family-name"
+PASS input.autocomplete is "honorific-suffix"
+PASS input.autocomplete is "nickname"
+PASS input.autocomplete is "organization-title"
+PASS input.autocomplete is "username"
+PASS input.autocomplete is "new-password"
+PASS input.autocomplete is "current-password"
+PASS input.autocomplete is "organization"
+PASS input.autocomplete is "street-address"
+PASS input.autocomplete is "address-line1"
+PASS input.autocomplete is "address-line2"
+PASS input.autocomplete is "address-line3"
+PASS input.autocomplete is "address-level4"
+PASS input.autocomplete is "address-level3"
+PASS input.autocomplete is "address-level2"
+PASS input.autocomplete is "address-level1"
+PASS input.autocomplete is "country"
+PASS input.autocomplete is "country-name"
+PASS input.autocomplete is "postal-code"
+PASS input.autocomplete is "cc-name"
+PASS input.autocomplete is "cc-given-name"
+PASS input.autocomplete is "cc-additional-name"
+PASS input.autocomplete is "cc-family-name"
+PASS input.autocomplete is "cc-number"
+PASS input.autocomplete is "cc-exp"
+PASS input.autocomplete is "cc-exp-month"
+PASS input.autocomplete is "cc-exp-year"
+PASS input.autocomplete is "cc-csc"
+PASS input.autocomplete is "cc-type"
+PASS input.autocomplete is "transaction-currency"
+PASS input.autocomplete is "transaction-amount"
+PASS input.autocomplete is "language"
+PASS input.autocomplete is "bday"
+PASS input.autocomplete is "bday-day"
+PASS input.autocomplete is "bday-month"
+PASS input.autocomplete is "bday-year"
+PASS input.autocomplete is "sex"
+PASS input.autocomplete is "url"
+PASS input.autocomplete is "photo"
+PASS input.autocomplete is "tel"
+PASS input.autocomplete is "tel-country-code"
+PASS input.autocomplete is "tel-national"
+PASS input.autocomplete is "tel-area-code"
+PASS input.autocomplete is "tel-local"
+PASS input.autocomplete is "tel-local-prefix"
+PASS input.autocomplete is "tel-local-suffix"
+PASS input.autocomplete is "tel-extension"
+PASS input.autocomplete is "email"
+PASS input.autocomplete is "impp"
+
+Contact scope:
+PASS input.autocomplete is "home tel"
+PASS input.autocomplete is "home tel-country-code"
+PASS input.autocomplete is "home tel-national"
+PASS input.autocomplete is "home tel-area-code"
+PASS input.autocomplete is "home tel-local"
+PASS input.autocomplete is "home tel-local-prefix"
+PASS input.autocomplete is "home tel-local-suffix"
+PASS input.autocomplete is "home tel-extension"
+PASS input.autocomplete is "home email"
+PASS input.autocomplete is "home impp"
+PASS input.autocomplete is "work tel"
+PASS input.autocomplete is "work tel-country-code"
+PASS input.autocomplete is "work tel-national"
+PASS input.autocomplete is "work tel-area-code"
+PASS input.autocomplete is "work tel-local"
+PASS input.autocomplete is "work tel-local-prefix"
+PASS input.autocomplete is "work tel-local-suffix"
+PASS input.autocomplete is "work tel-extension"
+PASS input.autocomplete is "work email"
+PASS input.autocomplete is "work impp"
+PASS input.autocomplete is "mobile tel"
+PASS input.autocomplete is "mobile tel-country-code"
+PASS input.autocomplete is "mobile tel-national"
+PASS input.autocomplete is "mobile tel-area-code"
+PASS input.autocomplete is "mobile tel-local"
+PASS input.autocomplete is "mobile tel-local-prefix"
+PASS input.autocomplete is "mobile tel-local-suffix"
+PASS input.autocomplete is "mobile tel-extension"
+PASS input.autocomplete is "mobile email"
+PASS input.autocomplete is "mobile impp"
+PASS input.autocomplete is "fax tel"
+PASS input.autocomplete is "fax tel-country-code"
+PASS input.autocomplete is "fax tel-national"
+PASS input.autocomplete is "fax tel-area-code"
+PASS input.autocomplete is "fax tel-local"
+PASS input.autocomplete is "fax tel-local-prefix"
+PASS input.autocomplete is "fax tel-local-suffix"
+PASS input.autocomplete is "fax tel-extension"
+PASS input.autocomplete is "fax email"
+PASS input.autocomplete is "fax impp"
+PASS input.autocomplete is "pager tel"
+PASS input.autocomplete is "pager tel-country-code"
+PASS input.autocomplete is "pager tel-national"
+PASS input.autocomplete is "pager tel-area-code"
+PASS input.autocomplete is "pager tel-local"
+PASS input.autocomplete is "pager tel-local-prefix"
+PASS input.autocomplete is "pager tel-local-suffix"
+PASS input.autocomplete is "pager tel-extension"
+PASS input.autocomplete is "pager email"
+PASS input.autocomplete is "pager impp"
+
+Mode:
+PASS input.autocomplete is "shipping street-address"
+PASS input.autocomplete is "shipping address-line1"
+PASS input.autocomplete is "shipping address-line2"
+PASS input.autocomplete is "shipping address-line3"
+PASS input.autocomplete is "shipping address-level4"
+PASS input.autocomplete is "shipping address-level3"
+PASS input.autocomplete is "shipping address-level2"
+PASS input.autocomplete is "shipping address-level1"
+PASS input.autocomplete is "shipping country"
+PASS input.autocomplete is "shipping country-name"
+PASS input.autocomplete is "shipping postal-code"
+PASS input.autocomplete is "billing street-address"
+PASS input.autocomplete is "billing address-line1"
+PASS input.autocomplete is "billing address-line2"
+PASS input.autocomplete is "billing address-line3"
+PASS input.autocomplete is "billing address-level4"
+PASS input.autocomplete is "billing address-level3"
+PASS input.autocomplete is "billing address-level2"
+PASS input.autocomplete is "billing address-level1"
+PASS input.autocomplete is "billing country"
+PASS input.autocomplete is "billing country-name"
+PASS input.autocomplete is "billing postal-code"
+
+Section:
+PASS input.autocomplete is "section-parent name"
+PASS input.autocomplete is "section-parent honorific-prefix"
+PASS input.autocomplete is "section-parent given-name"
+PASS input.autocomplete is "section-parent additional-name"
+PASS input.autocomplete is "section-parent family-name"
+PASS input.autocomplete is "section-parent honorific-suffix"
+PASS input.autocomplete is "section-parent nickname"
+PASS input.autocomplete is "section-parent organization-title"
+PASS input.autocomplete is "section-parent username"
+PASS input.autocomplete is "section-parent new-password"
+PASS input.autocomplete is "section-parent current-password"
+PASS input.autocomplete is "section-parent organization"
+PASS input.autocomplete is "section-parent street-address"
+PASS input.autocomplete is "section-parent address-line1"
+PASS input.autocomplete is "section-parent address-line2"
+PASS input.autocomplete is "section-parent address-line3"
+PASS input.autocomplete is "section-parent address-level4"
+PASS input.autocomplete is "section-parent address-level3"
+PASS input.autocomplete is "section-parent address-level2"
+PASS input.autocomplete is "section-parent address-level1"
+PASS input.autocomplete is "section-parent country"
+PASS input.autocomplete is "section-parent country-name"
+PASS input.autocomplete is "section-parent postal-code"
+PASS input.autocomplete is "section-parent cc-name"
+PASS input.autocomplete is "section-parent cc-given-name"
+PASS input.autocomplete is "section-parent cc-additional-name"
+PASS input.autocomplete is "section-parent cc-family-name"
+PASS input.autocomplete is "section-parent cc-number"
+PASS input.autocomplete is "section-parent cc-exp"
+PASS input.autocomplete is "section-parent cc-exp-month"
+PASS input.autocomplete is "section-parent cc-exp-year"
+PASS input.autocomplete is "section-parent cc-csc"
+PASS input.autocomplete is "section-parent cc-type"
+PASS input.autocomplete is "section-parent transaction-currency"
+PASS input.autocomplete is "section-parent transaction-amount"
+PASS input.autocomplete is "section-parent language"
+PASS input.autocomplete is "section-parent bday"
+PASS input.autocomplete is "section-parent bday-day"
+PASS input.autocomplete is "section-parent bday-month"
+PASS input.autocomplete is "section-parent bday-year"
+PASS input.autocomplete is "section-parent sex"
+PASS input.autocomplete is "section-parent url"
+PASS input.autocomplete is "section-parent photo"
+PASS input.autocomplete is "section-parent tel"
+PASS input.autocomplete is "section-parent tel-country-code"
+PASS input.autocomplete is "section-parent tel-national"
+PASS input.autocomplete is "section-parent tel-area-code"
+PASS input.autocomplete is "section-parent tel-local"
+PASS input.autocomplete is "section-parent tel-local-prefix"
+PASS input.autocomplete is "section-parent tel-local-suffix"
+PASS input.autocomplete is "section-parent tel-extension"
+PASS input.autocomplete is "section-parent email"
+PASS input.autocomplete is "section-parent impp"
+
+Invalid combinations:
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+PASS input.autocomplete is ""
+
+Non-autocompleteable controls:
+PASS button.autocomplete is "invalid"
+PASS keygen.autocomplete is "invalid"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: branches/safari-601.1.46-branch/LayoutTests/fast/forms/autocomplete-tokens.html (0 => 193551)


--- branches/safari-601.1.46-branch/LayoutTests/fast/forms/autocomplete-tokens.html	                        (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/fast/forms/autocomplete-tokens.html	2015-12-06 05:56:23 UTC (rev 193551)
@@ -0,0 +1,105 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+    </head>
+    <body>
+        <p id="description"></p>
+        <div id="console"></div>
+        <script>
+            description('Tests for valid autocomplete tokens on input, select, and textarea elements.');
+
+            var input = document.createElement('input');
+            var textarea = document.createElement('textarea');
+            var select = document.createElement('select');
+            var button = document.createElement('button');
+            var keygen = document.createElement('keygen');
+            var autocompleteableControls = [ input, textarea, select ];
+
+            var keywords = [ "name", "honorific-prefix", "given-name", "additional-name", "family-name", "honorific-suffix", "nickname", "organization-title", "username", "new-password", "current-password", "organization", "street-address", "address-line1", "address-line2", "address-line3", "address-level4", "address-level3", "address-level2", "address-level1", "country", "country-name", "postal-code", "cc-name", "cc-given-name", "cc-additional-name", "cc-family-name", "cc-number", "cc-exp", "cc-exp-month", "cc-exp-year", "cc-csc", "cc-type", "transaction-currency", "transaction-amount", "language", "bday", &quo
 t;bday-day", "bday-month", "bday-year", "sex", "url", "photo", "tel", "tel-country-code", "tel-national", "tel-area-code", "tel-local", "tel-local-prefix", "tel-local-suffix", "tel-extension", "email", "impp" ];
+
+            var modeTokens = [ "billing", "shipping" ];
+
+            debug('Valid keywords:');
+            keywords.forEach(function(keyword) {
+                input.autocomplete = keyword;
+                shouldBeEqualToString('input.autocomplete', keyword);
+            });
+
+            debug('');
+            debug('Contact scope:');
+            var contactTokens = [ "tel", "tel-country-code", "tel-national", "tel-area-code", "tel-local", "tel-local-prefix", "tel-local-suffix", "tel-extension", "email", "impp" ];
+            var contactScopeTokens = [ "home", "work", "mobile", "fax", "pager" ];
+            contactScopeTokens.forEach(function(scopeToken) {
+                contactTokens.forEach(function(contactToken) {
+                    input.autocomplete = scopeToken + " " + contactToken;
+                    shouldBeEqualToString('input.autocomplete', scopeToken + " " + contactToken);
+                })
+            });
+
+            debug('');
+            debug('Mode:');
+            var addressTokens = [ "street-address", "address-line1", "address-line2", "address-line3", "address-level4", "address-level3", "address-level2", "address-level1", "country", "country-name", "postal-code" ];
+            var modeTokens = [ "shipping", "billing" ];
+            modeTokens.forEach(function(modeToken) {
+                addressTokens.forEach(function(addressToken) {
+                    input.autocomplete = modeToken + " " + addressToken;
+                    shouldBeEqualToString('input.autocomplete', modeToken + " " + addressToken);
+                })
+            });
+
+            debug('');
+            debug('Section:');
+            keywords.forEach(function(keyword) {
+                var value = "section-parent " + keyword;
+                input.autocomplete = value;
+                shouldBeEqualToString('input.autocomplete', value);
+            });
+
+            debug('');
+            debug('Invalid combinations:');
+            autocompleteableControls.forEach(function(control) {
+                 control.autocomplete = 'invalid';
+                 shouldBeEmptyString('input.autocomplete');
+            });
+            // Two normal tokens
+            input.autocomplete = "name name";
+            shouldBeEmptyString('input.autocomplete');
+
+            input.autocomplete = "name bday";
+            shouldBeEmptyString('input.autocomplete');
+
+            // Contact scope token + non-contact token.
+            input.autocomplete = "pager bday";
+            shouldBeEmptyString('input.autocomplete');
+
+            // Two contact scope tokens.
+            input.autocomplete = "home work tel";
+            shouldBeEmptyString('input.autocomplete');
+
+            // Two mode tokens.
+            input.autocomplete = "shipping billing tel";
+            shouldBeEmptyString('input.autocomplete');
+
+            // Two section tokens.
+            input.autocomplete = "section-a section-b tel";
+            shouldBeEmptyString('input.autocomplete');
+
+            // Anything + on/off.
+            input.autocomplete = "tel on";
+            shouldBeEmptyString('input.autocomplete');
+
+            input.autocomplete = "tel off";
+            shouldBeEmptyString('input.autocomplete');
+
+            debug('');
+            debug('Non-autocompleteable controls:');
+            // Buttons and keygens are not autocompleteable, so their autocomplete attribute is not sanitized.
+            button.autocomplete = 'invalid';
+            shouldBeEqualToString('button.autocomplete', 'invalid');
+            keygen.autocomplete = 'invalid';
+            shouldBeEqualToString('keygen.autocomplete', 'invalid');
+        </script>
+        <script src=""
+    </body>
+</html>

Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (193550 => 193551)


--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2015-12-06 05:56:23 UTC (rev 193551)
@@ -1,3 +1,48 @@
+2015-12-05  David Kilzer  <[email protected]>
+
+        Merge r191981. rdar://problem/23221177
+
+    2015-10-30  Jon Honeycutt  <[email protected]>
+
+        Implement support for the autocomplete attribute
+        https://bugs.webkit.org/show_bug.cgi?id=150731
+        rdar://problem/21078968
+
+        The autocomplete attribute is defined by
+        https://html.spec.whatwg.org/multipage/forms.html#autofill.
+
+        Reviewed by Brent Fulgham.
+
+        Test: fast/forms/autocomplete-tokens.html
+
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::isContactToken):
+        Return true if this is a contact token.
+        (WebCore::categoryForAutofillFieldToken):
+        Adds all of the autofill field tokens to a map, and returns the
+        category for a given token.
+        (WebCore::maxTokensForAutofillFieldCategory):
+        Return the maximum number of tokens an autofill category supports.
+        (WebCore::HTMLFormControlElement::parseAutocompleteAttribute):
+        Implement the processing model defined in
+        https://html.spec.whatwg.org/multipage/forms.html#processing-model-3
+        with respect to the IDL-exposed autofill value.
+        (WebCore::HTMLFormControlElement::setAutocomplete):
+        Set the autocomplete attribute to the given string.
+
+        * html/HTMLFormControlElement.h:
+        Declare setAutocomplete() and autocomplete().
+
+        * html/HTMLInputElement.idl:
+        Remove the Reflect attribute. We now have custom processing for getting
+        this attribute.
+
+        * html/HTMLSelectElement.idl:
+        Declare the autocomplete attribute.
+
+        * html/HTMLTextAreaElement.idl:
+        Ditto.
+
 2015-12-05  Matthew Hanson  <[email protected]>
 
         Merge r191155. rdar://problem/23772889

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLFormControlElement.cpp (193550 => 193551)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLFormControlElement.cpp	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLFormControlElement.cpp	2015-12-06 05:56:23 UTC (rev 193551)
@@ -594,4 +594,163 @@
     return nullptr;
 }
 
+static inline bool isContactToken(const AtomicString& token)
+{
+    return token == "home" || token == "work" || token == "mobile" || token == "fax" || token == "pager";
+}
+
+enum class AutofillCategory {
+    Invalid,
+    Off,
+    Automatic,
+    Normal,
+    Contact,
+};
+
+static inline AutofillCategory categoryForAutofillFieldToken(const AtomicString& token)
+{
+    static NeverDestroyed<HashMap<AtomicString, AutofillCategory>> map;
+    if (map.get().isEmpty()) {
+        map.get().add(AtomicString("off", AtomicString::ConstructFromLiteral), AutofillCategory::Off);
+        map.get().add(AtomicString("on", AtomicString::ConstructFromLiteral), AutofillCategory::Automatic);
+
+        map.get().add(AtomicString("name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("honorific-prefix", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("given-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("additional-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("family-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("honorific-suffix", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("nickname", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("username", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("new-password", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("current-password", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("organization-title", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("organization", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("street-address", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-line1", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-line2", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-line3", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-level4", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-level3", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-level2", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("address-level1", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("country", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("country-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("postal-code", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-given-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-additional-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-family-name", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-number", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-exp", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-exp-month", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-exp-year", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-csc", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("cc-type", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("transaction-currency", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("transaction-amount", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("language", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("bday", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("bday-day", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("bday-month", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("bday-year", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("sex", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("url", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+        map.get().add(AtomicString("photo", AtomicString::ConstructFromLiteral), AutofillCategory::Normal);
+
+        map.get().add(AtomicString("tel", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-country-code", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-national", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-area-code", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-local", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-local-prefix", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-local-suffix", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("tel-extension", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("email", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+        map.get().add(AtomicString("impp", AtomicString::ConstructFromLiteral), AutofillCategory::Contact);
+    }
+
+    return map.get().get(token);
+}
+
+static inline unsigned maxTokensForAutofillFieldCategory(AutofillCategory category)
+{
+    switch (category) {
+    case AutofillCategory::Invalid:
+        return 0;
+
+    case AutofillCategory::Automatic:
+    case AutofillCategory::Off:
+        return 1;
+
+    case AutofillCategory::Normal:
+        return 3;
+
+    case AutofillCategory::Contact:
+        return 4;
+    }
+    ASSERT_NOT_REACHED();
+    return 0;
+}
+
+// https://html.spec.whatwg.org/multipage/forms.html#processing-model-3
+String HTMLFormControlElement::autocomplete() const
+{
+    const AtomicString& attributeValue = fastGetAttribute(autocompleteAttr);
+    SpaceSplitString tokens(attributeValue, true);
+    if (tokens.isEmpty())
+        return String();
+
+    size_t currentTokenIndex = tokens.size() - 1;
+    const auto& fieldToken = tokens[currentTokenIndex];
+    auto category = categoryForAutofillFieldToken(fieldToken);
+    if (category == AutofillCategory::Invalid)
+        return String();
+
+    if (tokens.size() > maxTokensForAutofillFieldCategory(category))
+        return String();
+
+    bool wearingAutofillAnchorMantle = is<HTMLInputElement>(*this) && downcast<HTMLInputElement>(this)->isInputTypeHidden();
+    if ((category == AutofillCategory::Off || category == AutofillCategory::Automatic) && wearingAutofillAnchorMantle)
+        return String();
+
+    if (category == AutofillCategory::Off)
+        return ASCIILiteral("off");
+
+    if (category == AutofillCategory::Automatic)
+        return ASCIILiteral("on");
+
+    String result = fieldToken;
+    if (!currentTokenIndex--)
+        return result;
+
+    const auto& contactToken = tokens[currentTokenIndex];
+    if (category == AutofillCategory::Contact && isContactToken(contactToken)) {
+        result = contactToken + " " + result;
+        if (!currentTokenIndex--)
+            return result;
+    }
+
+    const auto& modeToken = tokens[currentTokenIndex];
+    if (modeToken == "shipping" || modeToken == "billing") {
+        result = modeToken + " " + result;
+        if (!currentTokenIndex--)
+            return result;
+    }
+
+    if (currentTokenIndex)
+        return String();
+
+    const auto& sectionToken = tokens[currentTokenIndex];
+    if (!sectionToken.startsWith("section-"))
+        return String();
+
+    return sectionToken + " " + result;
+}
+
+void HTMLFormControlElement::setAutocomplete(const String& value)
+{
+    setAttribute(autocompleteAttr, value);
+}
+
 } // namespace Webcore

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLFormControlElement.h (193550 => 193551)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLFormControlElement.h	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLFormControlElement.h	2015-12-06 05:56:23 UTC (rev 193551)
@@ -114,6 +114,9 @@
 
     static HTMLFormControlElement* enclosingFormControlElement(Node*);
 
+    String autocomplete() const;
+    void setAutocomplete(const String&);
+
     using Node::ref;
     using Node::deref;
 

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLInputElement.idl (193550 => 193551)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLInputElement.idl	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLInputElement.idl	2015-12-06 05:56:23 UTC (rev 193551)
@@ -22,7 +22,7 @@
 interface HTMLInputElement : HTMLElement {
     [Reflect] attribute DOMString accept;
     [Reflect] attribute DOMString alt;
-    [Reflect] attribute DOMString autocomplete;
+    attribute DOMString autocomplete;
     [Reflect] attribute boolean autofocus;
     [Reflect=checked] attribute boolean defaultChecked;
     attribute boolean checked;

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLSelectElement.idl (193550 => 193551)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLSelectElement.idl	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLSelectElement.idl	2015-12-06 05:56:23 UTC (rev 193551)
@@ -61,4 +61,6 @@
     void setCustomValidity([TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString error);
 
     readonly attribute NodeList labels;
+
+    attribute DOMString autocomplete;
 };

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLTextAreaElement.idl (193550 => 193551)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLTextAreaElement.idl	2015-12-06 05:56:04 UTC (rev 193550)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLTextAreaElement.idl	2015-12-06 05:56:23 UTC (rev 193551)
@@ -71,4 +71,6 @@
 #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
     [Reflect] attribute DOMString accessKey;
 #endif
+
+    attribute DOMString autocomplete;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to