<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[193549] branches/safari-601-branch</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/193549">193549</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-12-05 21:56:02 -0800 (Sat, 05 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/191981">r191981</a>. rdar://problem/23732379</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsChangeLog">branches/safari-601-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebCoreChangeLog">branches/safari-601-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601branchSourceWebCorehtmlHTMLFormControlElementcpp">branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.cpp</a></li>
<li><a href="#branchessafari601branchSourceWebCorehtmlHTMLFormControlElementh">branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.h</a></li>
<li><a href="#branchessafari601branchSourceWebCorehtmlHTMLInputElementidl">branches/safari-601-branch/Source/WebCore/html/HTMLInputElement.idl</a></li>
<li><a href="#branchessafari601branchSourceWebCorehtmlHTMLSelectElementidl">branches/safari-601-branch/Source/WebCore/html/HTMLSelectElement.idl</a></li>
<li><a href="#branchessafari601branchSourceWebCorehtmlHTMLTextAreaElementidl">branches/safari-601-branch/Source/WebCore/html/HTMLTextAreaElement.idl</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari601branchLayoutTestsfastformsautocompletetokensexpectedtxt">branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt</a></li>
<li><a href="#branchessafari601branchLayoutTestsfastformsautocompletetokenshtml">branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/LayoutTests/ChangeLog (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/ChangeLog        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/LayoutTests/ChangeLog        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-12-05 David Kilzer <ddkilzer@apple.com>
+
+ Merge r191981. rdar://problem/23732379
+
+ 2015-10-30 Jon Honeycutt <jhoneycutt@apple.com>
+
+ 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.
+
</ins><span class="cx"> 2015-12-05 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r190564. rdar://problem/23769747
</span></span></pre></div>
<a id="branchessafari601branchLayoutTestsfastformsautocompletetokensexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt (0 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt         (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens-expected.txt        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -0,0 +1,211 @@
</span><ins>+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
+
</ins></span></pre></div>
<a id="branchessafari601branchLayoutTestsfastformsautocompletetokenshtml"></a>
<div class="addfile"><h4>Added: branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens.html (0 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens.html         (rev 0)
+++ branches/safari-601-branch/LayoutTests/fast/forms/autocomplete-tokens.html        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -0,0 +1,105 @@
</span><ins>+<!DOCTYPE html>
+<html>
+ <head>
+ <script src="../../resources/js-test-pre.js"></script>
+ </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="../../resources/js-test-post.js"></script>
+ </body>
+</html>
</ins></span></pre></div>
<a id="branchessafari601branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/ChangeLog (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/ChangeLog        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/Source/WebCore/ChangeLog        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2015-12-05 David Kilzer <ddkilzer@apple.com>
+
+ Merge r191981. rdar://problem/23732379
+
+ 2015-10-30 Jon Honeycutt <jhoneycutt@apple.com>
+
+ 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.
+
</ins><span class="cx"> 2015-12-05 Dana Burkart <dburkart@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r190564. rdar://problem/23769747
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorehtmlHTMLFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.cpp (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.cpp        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.cpp        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -594,4 +594,163 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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);
+}
+
</ins><span class="cx"> } // namespace Webcore
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorehtmlHTMLFormControlElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.h (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.h        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/Source/WebCore/html/HTMLFormControlElement.h        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -114,6 +114,9 @@
</span><span class="cx">
</span><span class="cx"> static HTMLFormControlElement* enclosingFormControlElement(Node*);
</span><span class="cx">
</span><ins>+ String autocomplete() const;
+ void setAutocomplete(const String&);
+
</ins><span class="cx"> using Node::ref;
</span><span class="cx"> using Node::deref;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorehtmlHTMLInputElementidl"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/html/HTMLInputElement.idl (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/html/HTMLInputElement.idl        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/Source/WebCore/html/HTMLInputElement.idl        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx"> interface HTMLInputElement : HTMLElement {
</span><span class="cx"> [Reflect] attribute DOMString accept;
</span><span class="cx"> [Reflect] attribute DOMString alt;
</span><del>- [Reflect] attribute DOMString autocomplete;
</del><ins>+ attribute DOMString autocomplete;
</ins><span class="cx"> [Reflect] attribute boolean autofocus;
</span><span class="cx"> [Reflect=checked] attribute boolean defaultChecked;
</span><span class="cx"> attribute boolean checked;
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorehtmlHTMLSelectElementidl"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/html/HTMLSelectElement.idl (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/html/HTMLSelectElement.idl        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/Source/WebCore/html/HTMLSelectElement.idl        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -61,4 +61,6 @@
</span><span class="cx"> void setCustomValidity([TreatNullAs=NullString, TreatUndefinedAs=NullString] DOMString error);
</span><span class="cx">
</span><span class="cx"> readonly attribute NodeList labels;
</span><ins>+
+ attribute DOMString autocomplete;
</ins><span class="cx"> };
</span></span></pre></div>
<a id="branchessafari601branchSourceWebCorehtmlHTMLTextAreaElementidl"></a>
<div class="modfile"><h4>Modified: branches/safari-601-branch/Source/WebCore/html/HTMLTextAreaElement.idl (193548 => 193549)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601-branch/Source/WebCore/html/HTMLTextAreaElement.idl        2015-12-06 03:08:17 UTC (rev 193548)
+++ branches/safari-601-branch/Source/WebCore/html/HTMLTextAreaElement.idl        2015-12-06 05:56:02 UTC (rev 193549)
</span><span class="lines">@@ -71,4 +71,6 @@
</span><span class="cx"> #if defined(LANGUAGE_OBJECTIVE_C) && LANGUAGE_OBJECTIVE_C
</span><span class="cx"> [Reflect] attribute DOMString accessKey;
</span><span class="cx"> #endif
</span><ins>+
+ attribute DOMString autocomplete;
</ins><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>