<!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>[197626] trunk</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/197626">197626</a></dd>
<dt>Author</dt> <dd>weinig@apple.com</dd>
<dt>Date</dt> <dd>2016-03-05 18:17:29 -0800 (Sat, 05 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add support for processing the autofill field name out of form control elements ultimately to aid input methods
<rdar://problem/23041180>
https://bugs.webkit.org/show_bug.cgi?id=155079
Reviewed by Enrica Casucci.
Source/WebCore:
Added additional cases to fast/forms/autocomplete-tokens.html.
* WebCore.xcodeproj/project.pbxproj:
Add Autofill.h/cpp
* html/Autofill.cpp: Added.
(WebCore::fieldNameMap):
(WebCore::toAutofillFieldName):
(WebCore::isContactToken):
(WebCore::maxTokensForAutofillFieldCategory):
(WebCore::AutofillData::createFromHTMLFormControlElement):
* html/Autofill.h: Added.
(WebCore::AutofillData::AutofillData):
Refactored the autofill data processing algorithm into it's own file and added support
returning not just the IDL-exposed autofill value but also the autofill field name. The
code is structured simply enough that if we find a need for the hint set or scope information
we could return it as well.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::autocomplete):
(WebCore::HTMLFormControlElement::setAutocomplete):
(WebCore::HTMLFormControlElement::autofillMantle):
(WebCore::HTMLFormControlElement::autofillData):
Use AutofillData to implement these.
* html/HTMLFormControlElement.h:
Expose accessor for mantle and AutofillData.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::autocomplete):
* html/HTMLFormElement.h:
Switch to return an AtomicString as it will always
return one of two known values.
* testing/Internals.cpp:
(WebCore::Internals::autofillFieldName):
* testing/Internals.h:
* testing/Internals.idl:
Add accessor of the field name for testing purposes.
Source/WebKit2:
* Shared/AssistedNodeInformation.cpp:
(WebKit::AssistedNodeInformation::encode):
(WebKit::AssistedNodeInformation::decode):
* Shared/AssistedNodeInformation.h:
Add AutofillFieldName. Convert some coders to use encodeEnum/decodeEnum instead of casting.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView textInputTraits]):
Map AutofillFieldNames to the associated UITextContentTypes.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getAssistedNodeInformation):
Extract the AutofillFieldNames onto the AssistedNodeInformation for <input> elements
and <textarea> elements.
LayoutTests:
* fast/forms/autocomplete-tokens-expected.txt:
* fast/forms/autocomplete-tokens.html:
Update test to also test field names, as they are now exposed via internals.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastformsautocompletetokensexpectedtxt">trunk/LayoutTests/fast/forms/autocomplete-tokens-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsautocompletetokenshtml">trunk/LayoutTests/fast/forms/autocomplete-tokens.html</a></li>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlElementcpp">trunk/Source/WebCore/html/HTMLFormControlElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormControlElementh">trunk/Source/WebCore/html/HTMLFormControlElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormElementcpp">trunk/Source/WebCore/html/HTMLFormElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLFormElementh">trunk/Source/WebCore/html/HTMLFormElement.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedAssistedNodeInformationcpp">trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedAssistedNodeInformationh">trunk/Source/WebKit2/Shared/AssistedNodeInformation.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorehtmlAutofillcpp">trunk/Source/WebCore/html/Autofill.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlAutofillh">trunk/Source/WebCore/html/Autofill.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/LayoutTests/ChangeLog        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-03-05 Sam Weinig <sam@webkit.org>
+
+ Add support for processing the autofill field name out of form control elements ultimately to aid input methods
+ <rdar://problem/23041180>
+ https://bugs.webkit.org/show_bug.cgi?id=155079
+
+ Reviewed by Enrica Casucci.
+
+ * fast/forms/autocomplete-tokens-expected.txt:
+ * fast/forms/autocomplete-tokens.html:
+ Update test to also test field names, as they are now exposed via internals.
+
</ins><span class="cx"> 2016-03-05 Simon Fraser <simon.fraser@apple.com>
</span><span class="cx">
</span><span class="cx"> Add support for the object-position CSS property
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsautocompletetokensexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/autocomplete-tokens-expected.txt (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/autocomplete-tokens-expected.txt        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/LayoutTests/fast/forms/autocomplete-tokens-expected.txt        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -5,202 +5,395 @@
</span><span class="cx">
</span><span class="cx"> Valid keywords:
</span><span class="cx"> PASS input.autocomplete is "name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "name"
</ins><span class="cx"> PASS input.autocomplete is "honorific-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "honorific-prefix"
</ins><span class="cx"> PASS input.autocomplete is "given-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "given-name"
</ins><span class="cx"> PASS input.autocomplete is "additional-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "additional-name"
</ins><span class="cx"> PASS input.autocomplete is "family-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "family-name"
</ins><span class="cx"> PASS input.autocomplete is "honorific-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "honorific-suffix"
</ins><span class="cx"> PASS input.autocomplete is "nickname"
</span><ins>+PASS window.internals.autofillFieldName(input) is "nickname"
</ins><span class="cx"> PASS input.autocomplete is "organization-title"
</span><ins>+PASS window.internals.autofillFieldName(input) is "organization-title"
</ins><span class="cx"> PASS input.autocomplete is "username"
</span><ins>+PASS window.internals.autofillFieldName(input) is "username"
</ins><span class="cx"> PASS input.autocomplete is "new-password"
</span><ins>+PASS window.internals.autofillFieldName(input) is "new-password"
</ins><span class="cx"> PASS input.autocomplete is "current-password"
</span><ins>+PASS window.internals.autofillFieldName(input) is "current-password"
</ins><span class="cx"> PASS input.autocomplete is "organization"
</span><ins>+PASS window.internals.autofillFieldName(input) is "organization"
</ins><span class="cx"> PASS input.autocomplete is "street-address"
</span><ins>+PASS window.internals.autofillFieldName(input) is "street-address"
</ins><span class="cx"> PASS input.autocomplete is "address-line1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line1"
</ins><span class="cx"> PASS input.autocomplete is "address-line2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line2"
</ins><span class="cx"> PASS input.autocomplete is "address-line3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line3"
</ins><span class="cx"> PASS input.autocomplete is "address-level4"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level4"
</ins><span class="cx"> PASS input.autocomplete is "address-level3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level3"
</ins><span class="cx"> PASS input.autocomplete is "address-level2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level2"
</ins><span class="cx"> PASS input.autocomplete is "address-level1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level1"
</ins><span class="cx"> PASS input.autocomplete is "country"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country"
</ins><span class="cx"> PASS input.autocomplete is "country-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country-name"
</ins><span class="cx"> PASS input.autocomplete is "postal-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "postal-code"
</ins><span class="cx"> PASS input.autocomplete is "cc-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-name"
</ins><span class="cx"> PASS input.autocomplete is "cc-given-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-given-name"
</ins><span class="cx"> PASS input.autocomplete is "cc-additional-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-additional-name"
</ins><span class="cx"> PASS input.autocomplete is "cc-family-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-family-name"
</ins><span class="cx"> PASS input.autocomplete is "cc-number"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-number"
</ins><span class="cx"> PASS input.autocomplete is "cc-exp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-exp"
</ins><span class="cx"> PASS input.autocomplete is "cc-exp-month"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-exp-month"
</ins><span class="cx"> PASS input.autocomplete is "cc-exp-year"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-exp-year"
</ins><span class="cx"> PASS input.autocomplete is "cc-csc"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-csc"
</ins><span class="cx"> PASS input.autocomplete is "cc-type"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-type"
</ins><span class="cx"> PASS input.autocomplete is "transaction-currency"
</span><ins>+PASS window.internals.autofillFieldName(input) is "transaction-currency"
</ins><span class="cx"> PASS input.autocomplete is "transaction-amount"
</span><ins>+PASS window.internals.autofillFieldName(input) is "transaction-amount"
</ins><span class="cx"> PASS input.autocomplete is "language"
</span><ins>+PASS window.internals.autofillFieldName(input) is "language"
</ins><span class="cx"> PASS input.autocomplete is "bday"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday"
</ins><span class="cx"> PASS input.autocomplete is "bday-day"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday-day"
</ins><span class="cx"> PASS input.autocomplete is "bday-month"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday-month"
</ins><span class="cx"> PASS input.autocomplete is "bday-year"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday-year"
</ins><span class="cx"> PASS input.autocomplete is "sex"
</span><ins>+PASS window.internals.autofillFieldName(input) is "sex"
</ins><span class="cx"> PASS input.autocomplete is "url"
</span><ins>+PASS window.internals.autofillFieldName(input) is "url"
</ins><span class="cx"> PASS input.autocomplete is "photo"
</span><ins>+PASS window.internals.autofillFieldName(input) is "photo"
</ins><span class="cx"> PASS input.autocomplete is "tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx">
</span><span class="cx"> Contact scope:
</span><span class="cx"> PASS input.autocomplete is "home tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "home tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "home tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "home tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "home tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "home tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "home tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "home tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "home email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "home impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx"> PASS input.autocomplete is "work tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "work tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "work tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "work tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "work tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "work tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "work tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "work tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "work email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "work impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "mobile tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "mobile email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "mobile impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx"> PASS input.autocomplete is "fax tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "fax tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "fax email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "fax impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx"> PASS input.autocomplete is "pager tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "pager tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "pager email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "pager impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx">
</span><span class="cx"> Mode:
</span><span class="cx"> PASS input.autocomplete is "shipping street-address"
</span><ins>+PASS window.internals.autofillFieldName(input) is "street-address"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-line1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line1"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-line2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line2"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-line3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line3"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-level4"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level4"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-level3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level3"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-level2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level2"
</ins><span class="cx"> PASS input.autocomplete is "shipping address-level1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level1"
</ins><span class="cx"> PASS input.autocomplete is "shipping country"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country"
</ins><span class="cx"> PASS input.autocomplete is "shipping country-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country-name"
</ins><span class="cx"> PASS input.autocomplete is "shipping postal-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "postal-code"
</ins><span class="cx"> PASS input.autocomplete is "billing street-address"
</span><ins>+PASS window.internals.autofillFieldName(input) is "street-address"
</ins><span class="cx"> PASS input.autocomplete is "billing address-line1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line1"
</ins><span class="cx"> PASS input.autocomplete is "billing address-line2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line2"
</ins><span class="cx"> PASS input.autocomplete is "billing address-line3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line3"
</ins><span class="cx"> PASS input.autocomplete is "billing address-level4"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level4"
</ins><span class="cx"> PASS input.autocomplete is "billing address-level3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level3"
</ins><span class="cx"> PASS input.autocomplete is "billing address-level2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level2"
</ins><span class="cx"> PASS input.autocomplete is "billing address-level1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level1"
</ins><span class="cx"> PASS input.autocomplete is "billing country"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country"
</ins><span class="cx"> PASS input.autocomplete is "billing country-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country-name"
</ins><span class="cx"> PASS input.autocomplete is "billing postal-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "postal-code"
</ins><span class="cx">
</span><span class="cx"> Section:
</span><span class="cx"> PASS input.autocomplete is "section-parent name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent honorific-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "honorific-prefix"
</ins><span class="cx"> PASS input.autocomplete is "section-parent given-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "given-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent additional-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "additional-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent family-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "family-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent honorific-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "honorific-suffix"
</ins><span class="cx"> PASS input.autocomplete is "section-parent nickname"
</span><ins>+PASS window.internals.autofillFieldName(input) is "nickname"
</ins><span class="cx"> PASS input.autocomplete is "section-parent organization-title"
</span><ins>+PASS window.internals.autofillFieldName(input) is "organization-title"
</ins><span class="cx"> PASS input.autocomplete is "section-parent username"
</span><ins>+PASS window.internals.autofillFieldName(input) is "username"
</ins><span class="cx"> PASS input.autocomplete is "section-parent new-password"
</span><ins>+PASS window.internals.autofillFieldName(input) is "new-password"
</ins><span class="cx"> PASS input.autocomplete is "section-parent current-password"
</span><ins>+PASS window.internals.autofillFieldName(input) is "current-password"
</ins><span class="cx"> PASS input.autocomplete is "section-parent organization"
</span><ins>+PASS window.internals.autofillFieldName(input) is "organization"
</ins><span class="cx"> PASS input.autocomplete is "section-parent street-address"
</span><ins>+PASS window.internals.autofillFieldName(input) is "street-address"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-line1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line1"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-line2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line2"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-line3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-line3"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-level4"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level4"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-level3"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level3"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-level2"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level2"
</ins><span class="cx"> PASS input.autocomplete is "section-parent address-level1"
</span><ins>+PASS window.internals.autofillFieldName(input) is "address-level1"
</ins><span class="cx"> PASS input.autocomplete is "section-parent country"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country"
</ins><span class="cx"> PASS input.autocomplete is "section-parent country-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "country-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent postal-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "postal-code"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-given-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-given-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-additional-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-additional-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-family-name"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-family-name"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-number"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-number"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-exp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-exp"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-exp-month"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-exp-month"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-exp-year"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-exp-year"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-csc"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-csc"
</ins><span class="cx"> PASS input.autocomplete is "section-parent cc-type"
</span><ins>+PASS window.internals.autofillFieldName(input) is "cc-type"
</ins><span class="cx"> PASS input.autocomplete is "section-parent transaction-currency"
</span><ins>+PASS window.internals.autofillFieldName(input) is "transaction-currency"
</ins><span class="cx"> PASS input.autocomplete is "section-parent transaction-amount"
</span><ins>+PASS window.internals.autofillFieldName(input) is "transaction-amount"
</ins><span class="cx"> PASS input.autocomplete is "section-parent language"
</span><ins>+PASS window.internals.autofillFieldName(input) is "language"
</ins><span class="cx"> PASS input.autocomplete is "section-parent bday"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday"
</ins><span class="cx"> PASS input.autocomplete is "section-parent bday-day"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday-day"
</ins><span class="cx"> PASS input.autocomplete is "section-parent bday-month"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday-month"
</ins><span class="cx"> PASS input.autocomplete is "section-parent bday-year"
</span><ins>+PASS window.internals.autofillFieldName(input) is "bday-year"
</ins><span class="cx"> PASS input.autocomplete is "section-parent sex"
</span><ins>+PASS window.internals.autofillFieldName(input) is "sex"
</ins><span class="cx"> PASS input.autocomplete is "section-parent url"
</span><ins>+PASS window.internals.autofillFieldName(input) is "url"
</ins><span class="cx"> PASS input.autocomplete is "section-parent photo"
</span><ins>+PASS window.internals.autofillFieldName(input) is "photo"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-country-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-country-code"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-national"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-national"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-area-code"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-area-code"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-local"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-local-prefix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-prefix"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-local-suffix"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-local-suffix"
</ins><span class="cx"> PASS input.autocomplete is "section-parent tel-extension"
</span><ins>+PASS window.internals.autofillFieldName(input) is "tel-extension"
</ins><span class="cx"> PASS input.autocomplete is "section-parent email"
</span><ins>+PASS window.internals.autofillFieldName(input) is "email"
</ins><span class="cx"> PASS input.autocomplete is "section-parent impp"
</span><ins>+PASS window.internals.autofillFieldName(input) is "impp"
</ins><span class="cx">
</span><span class="cx"> Invalid combinations:
</span><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
</ins><span class="cx"> PASS input.autocomplete is ""
</span><ins>+PASS window.internals.autofillFieldName(input) is "on"
+PASS inputInAutocompleteOffForm.autocomplete is ""
+PASS window.internals.autofillFieldName(inputInAutocompleteOffForm) is "off"
+PASS inputInAutocompleteOffForm.autocomplete is ""
+PASS window.internals.autofillFieldName(inputInAutocompleteOffForm) is "on"
</ins><span class="cx">
</span><span class="cx"> Non-autocompleteable controls:
</span><span class="cx"> PASS button.autocomplete is "invalid"
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsautocompletetokenshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/autocomplete-tokens.html (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/autocomplete-tokens.html        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/LayoutTests/fast/forms/autocomplete-tokens.html        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -24,6 +24,8 @@
</span><span class="cx"> keywords.forEach(keyword => {
</span><span class="cx"> input.autocomplete = keyword;
</span><span class="cx"> shouldBeEqualToString('input.autocomplete', keyword);
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', keyword);
</ins><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> debug('');
</span><span class="lines">@@ -34,6 +36,8 @@
</span><span class="cx"> contactTokens.forEach(contactToken => {
</span><span class="cx"> input.autocomplete = scopeToken + " " + contactToken;
</span><span class="cx"> shouldBeEqualToString('input.autocomplete', scopeToken + " " + contactToken);
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', contactToken);
</ins><span class="cx"> })
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -45,6 +49,8 @@
</span><span class="cx"> addressTokens.forEach(addressToken => {
</span><span class="cx"> input.autocomplete = modeToken + " " + addressToken;
</span><span class="cx"> shouldBeEqualToString('input.autocomplete', modeToken + " " + addressToken);
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', addressToken);
</ins><span class="cx"> })
</span><span class="cx"> });
</span><span class="cx">
</span><span class="lines">@@ -54,6 +60,8 @@
</span><span class="cx"> var value = "section-parent " + keyword;
</span><span class="cx"> input.autocomplete = value;
</span><span class="cx"> shouldBeEqualToString('input.autocomplete', value);
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', keyword);
</ins><span class="cx"> });
</span><span class="cx">
</span><span class="cx"> debug('');
</span><span class="lines">@@ -61,37 +69,72 @@
</span><span class="cx"> autocompleteableControls.forEach(control => {
</span><span class="cx"> control.autocomplete = 'invalid';
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx"> });
</span><span class="cx"> // Two normal tokens
</span><span class="cx"> input.autocomplete = "name name";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> input.autocomplete = "name bday";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> // Contact scope token + non-contact token.
</span><span class="cx"> input.autocomplete = "pager bday";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> // Two contact scope tokens.
</span><span class="cx"> input.autocomplete = "home work tel";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> // Two mode tokens.
</span><span class="cx"> input.autocomplete = "shipping billing tel";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> // Two section tokens.
</span><span class="cx"> input.autocomplete = "section-a section-b tel";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> // Anything + on/off.
</span><span class="cx"> input.autocomplete = "tel on";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><span class="cx"> input.autocomplete = "tel off";
</span><span class="cx"> shouldBeEmptyString('input.autocomplete');
</span><ins>+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(input)', "on");
</ins><span class="cx">
</span><ins>+ // Test dynamically changing the form owner's autocomplete attribute
+ // to ensure the field name correctly reflects it.
+ var form = document.createElement("form");
+ var inputInAutocompleteOffForm = document.createElement("input");
+ form.appendChild(inputInAutocompleteOffForm);
+ document.body.appendChild(form);
+ form.autocomplete = "off";
+ inputInAutocompleteOffForm.autocomplete = "";
+ shouldBeEmptyString('inputInAutocompleteOffForm.autocomplete');
+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(inputInAutocompleteOffForm)', "off");
+
+ form.autocomplete = "on";
+ shouldBeEmptyString('inputInAutocompleteOffForm.autocomplete');
+ if (window.internals)
+ shouldBeEqualToString('window.internals.autofillFieldName(inputInAutocompleteOffForm)', "on");
+
</ins><span class="cx"> debug('');
</span><span class="cx"> debug('Non-autocompleteable controls:');
</span><span class="cx"> // Buttons and keygens are not autocompleteable, so their autocomplete attribute is not sanitized.
</span></span></pre></div>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/CMakeLists.txt        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -1612,6 +1612,7 @@
</span><span class="cx"> history/PageCache.cpp
</span><span class="cx">
</span><span class="cx"> html/AttributeDOMTokenList.cpp
</span><ins>+ html/Autofill.cpp
</ins><span class="cx"> html/BaseButtonInputType.cpp
</span><span class="cx"> html/BaseCheckableInputType.cpp
</span><span class="cx"> html/BaseChooserOnlyDateAndTimeInputType.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/ChangeLog        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -1,3 +1,51 @@
</span><ins>+2016-03-05 Sam Weinig <sam@webkit.org>
+
+ Add support for processing the autofill field name out of form control elements ultimately to aid input methods
+ <rdar://problem/23041180>
+ https://bugs.webkit.org/show_bug.cgi?id=155079
+
+ Reviewed by Enrica Casucci.
+
+ Added additional cases to fast/forms/autocomplete-tokens.html.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ Add Autofill.h/cpp
+
+ * html/Autofill.cpp: Added.
+ (WebCore::fieldNameMap):
+ (WebCore::toAutofillFieldName):
+ (WebCore::isContactToken):
+ (WebCore::maxTokensForAutofillFieldCategory):
+ (WebCore::AutofillData::createFromHTMLFormControlElement):
+ * html/Autofill.h: Added.
+ (WebCore::AutofillData::AutofillData):
+ Refactored the autofill data processing algorithm into it's own file and added support
+ returning not just the IDL-exposed autofill value but also the autofill field name. The
+ code is structured simply enough that if we find a need for the hint set or scope information
+ we could return it as well.
+
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::autocomplete):
+ (WebCore::HTMLFormControlElement::setAutocomplete):
+ (WebCore::HTMLFormControlElement::autofillMantle):
+ (WebCore::HTMLFormControlElement::autofillData):
+ Use AutofillData to implement these.
+
+ * html/HTMLFormControlElement.h:
+ Expose accessor for mantle and AutofillData.
+
+ * html/HTMLFormElement.cpp:
+ (WebCore::HTMLFormElement::autocomplete):
+ * html/HTMLFormElement.h:
+ Switch to return an AtomicString as it will always
+ return one of two known values.
+
+ * testing/Internals.cpp:
+ (WebCore::Internals::autofillFieldName):
+ * testing/Internals.h:
+ * testing/Internals.idl:
+ Add accessor of the field name for testing purposes.
+
</ins><span class="cx"> 2016-03-05 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> Build fix after r197612 (under ASAN/GuardMalloc).
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -2721,6 +2721,8 @@
</span><span class="cx">                 7AF9B20E18CFB5F400C64BEF /* JSVTTRegionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */; };
</span><span class="cx">                 7AF9B20F18CFB5F400C64BEF /* JSVTTRegionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */; };
</span><span class="cx">                 7BE7427381FA906FBB4F0F2C /* JSSVGGraphicsElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 950C4C02BED8936F818E2F99 /* JSSVGGraphicsElement.h */; };
</span><ins>+                7C1843FD1C8B7283002EB973 /* Autofill.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1843FB1C8B7283002EB973 /* Autofill.cpp */; };
+                7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1843FC1C8B7283002EB973 /* Autofill.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 7C1E97271A9F9834007BF0FB /* AutoFillButtonElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */; };
</span><span class="cx">                 7C1E97281A9F9834007BF0FB /* AutoFillButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */; };
</span><span class="cx">                 7C2BDD3D17C7F98C0038FF15 /* JSDOMGlobalObjectTask.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */; };
</span><span class="lines">@@ -10345,6 +10347,8 @@
</span><span class="cx">                 7AF9B20A18CFB5F300C64BEF /* JSVTTRegionList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSVTTRegionList.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7AF9B20B18CFB5F300C64BEF /* JSVTTRegionList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVTTRegionList.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C0406121C66EE9C00AF0711 /* NSScrollerImpSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSScrollerImpSPI.h; sourceTree = "<group>"; };
</span><ins>+                7C1843FB1C8B7283002EB973 /* Autofill.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Autofill.cpp; sourceTree = "<group>"; };
+                7C1843FC1C8B7283002EB973 /* Autofill.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Autofill.h; sourceTree = "<group>"; };
</ins><span class="cx">                 7C1E97251A9F9834007BF0FB /* AutoFillButtonElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AutoFillButtonElement.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 7C1E97261A9F9834007BF0FB /* AutoFillButtonElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoFillButtonElement.h; sourceTree = "<group>"; };
</span><span class="cx">                 7C2BDD3B17C7F98B0038FF15 /* JSDOMGlobalObjectTask.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMGlobalObjectTask.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -19035,6 +19039,8 @@
</span><span class="cx">                                 B1AD4E7713A12A7200846B27 /* track */,
</span><span class="cx">                                 A5F6E16C132ED46E008EDAE3 /* Autocapitalize.cpp */,
</span><span class="cx">                                 A501920C132EBF2E008BFE55 /* Autocapitalize.h */,
</span><ins>+                                7C1843FB1C8B7283002EB973 /* Autofill.cpp */,
+                                7C1843FC1C8B7283002EB973 /* Autofill.h */,
</ins><span class="cx">                                 379E61C5126CA5C300B63E8D /* BaseButtonInputType.cpp */,
</span><span class="cx">                                 379E61C6126CA5C300B63E8D /* BaseButtonInputType.h */,
</span><span class="cx">                                 379E61C7126CA5C300B63E8D /* BaseCheckableInputType.cpp */,
</span><span class="lines">@@ -26776,6 +26782,7 @@
</span><span class="cx">                                 B59DD69D11902A42007E9684 /* JSSQLTransactionCallback.h in Headers */,
</span><span class="cx">                                 B59DD6A111902A52007E9684 /* JSSQLTransactionErrorCallback.h in Headers */,
</span><span class="cx">                                 51E0BAEB0DA55D4A00A9E417 /* JSStorageEvent.h in Headers */,
</span><ins>+                                7C1843FE1C8B7283002EB973 /* Autofill.h in Headers */,
</ins><span class="cx">                                 89F60CDA15809D760075E157 /* JSStorageInfo.h in Headers */,
</span><span class="cx">                                 0FF5026A102BA9430066F39A /* JSStyleMedia.h in Headers */,
</span><span class="cx">                                 BCE0139B0C0BEF180043860A /* JSStyleSheet.h in Headers */,
</span><span class="lines">@@ -31159,6 +31166,7 @@
</span><span class="cx">                                 93309E04099E64920056E581 /* RemoveNodeCommand.cpp in Sources */,
</span><span class="cx">                                 93309E06099E64920056E581 /* RemoveNodePreservingChildrenCommand.cpp in Sources */,
</span><span class="cx">                                 7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */,
</span><ins>+                                7C1843FD1C8B7283002EB973 /* Autofill.cpp in Sources */,
</ins><span class="cx">                                 BCEA485F097D93020094C9E4 /* RenderBlock.cpp in Sources */,
</span><span class="cx">                                 BC10D76717D8EE6E005E2626 /* RenderBlockFlow.cpp in Sources */,
</span><span class="cx">                                 BCEA4852097D93020094C9E4 /* RenderBlockLineLayout.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlAutofillcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/html/Autofill.cpp (0 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/Autofill.cpp         (rev 0)
+++ trunk/Source/WebCore/html/Autofill.cpp        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -0,0 +1,316 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "Autofill.h"
+
+#include "HTMLFormControlElement.h"
+#include "HTMLFormElement.h"
+#include "HTMLNames.h"
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/AtomicStringHash.h>
+
+namespace WebCore {
+
+enum class AutofillCategory {
+ Off,
+ Automatic,
+ Normal,
+ Contact,
+};
+
+struct AutofillInfo {
+ AutofillFieldName fieldName;
+ AutofillCategory category;
+};
+
+static HashMap<AtomicString, AutofillInfo>& fieldNameMap()
+{
+ static NeverDestroyed<HashMap<AtomicString, AutofillInfo>> map;
+ if (map.get().isEmpty()) {
+ map.get().add(AtomicString("on", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::None, AutofillCategory::Off });
+ map.get().add(AtomicString("off", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::None, AutofillCategory::Automatic });
+ map.get().add(AtomicString("name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Name, AutofillCategory::Normal });
+ map.get().add(AtomicString("honorific-prefix", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::HonorificPrefix, AutofillCategory::Normal });
+ map.get().add(AtomicString("given-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::GivenName, AutofillCategory::Normal });
+ map.get().add(AtomicString("additional-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AdditionalName, AutofillCategory::Normal });
+ map.get().add(AtomicString("family-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::FamilyName, AutofillCategory::Normal });
+ map.get().add(AtomicString("honorific-suffix", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::HonorificSuffix, AutofillCategory::Normal });
+ map.get().add(AtomicString("nickname", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Nickname, AutofillCategory::Normal });
+ map.get().add(AtomicString("username", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Username, AutofillCategory::Normal });
+ map.get().add(AtomicString("new-password", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::NewPassword, AutofillCategory::Normal });
+ map.get().add(AtomicString("current-password", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CurrentPassword, AutofillCategory::Normal });
+ map.get().add(AtomicString("organization-title", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::OrganizationTitle, AutofillCategory::Normal });
+ map.get().add(AtomicString("organization", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Organization, AutofillCategory::Normal });
+ map.get().add(AtomicString("street-address", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::StreetAddress, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-line1", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLine1, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-line2", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLine2, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-line3", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLine3, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-level4", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLevel4, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-level3", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLevel3, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-level2", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLevel2, AutofillCategory::Normal });
+ map.get().add(AtomicString("address-level1", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::AddressLevel1, AutofillCategory::Normal });
+ map.get().add(AtomicString("country", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Country, AutofillCategory::Normal });
+ map.get().add(AtomicString("country-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CountryName, AutofillCategory::Normal });
+ map.get().add(AtomicString("postal-code", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::PostalCode, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcName, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-given-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcGivenName, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-additional-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcAdditionalName, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-family-name", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcFamilyName, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-number", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcNumber, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-exp", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcExp, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-exp-month", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcExpMonth, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-exp-year", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcExpYear, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-csc", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcCsc, AutofillCategory::Normal });
+ map.get().add(AtomicString("cc-type", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::CcType, AutofillCategory::Normal });
+ map.get().add(AtomicString("transaction-currency", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TransactionCurrency, AutofillCategory::Normal });
+ map.get().add(AtomicString("transaction-amount", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TransactionAmount, AutofillCategory::Normal });
+ map.get().add(AtomicString("language", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Language, AutofillCategory::Normal });
+ map.get().add(AtomicString("bday", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Bday, AutofillCategory::Normal });
+ map.get().add(AtomicString("bday-day", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::BdayDay, AutofillCategory::Normal });
+ map.get().add(AtomicString("bday-month", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::BdayMonth, AutofillCategory::Normal });
+ map.get().add(AtomicString("bday-year", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::BdayYear, AutofillCategory::Normal });
+ map.get().add(AtomicString("sex", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Sex, AutofillCategory::Normal });
+ map.get().add(AtomicString("url", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::URL, AutofillCategory::Normal });
+ map.get().add(AtomicString("photo", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Photo, AutofillCategory::Normal });
+
+ map.get().add(AtomicString("tel", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Tel, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-country-code", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelCountryCode, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-national", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelNational, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-area-code", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelAreaCode, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-local", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelLocal, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-local-prefix", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelLocalPrefix, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-local-suffix", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelLocalSuffix, AutofillCategory::Contact });
+ map.get().add(AtomicString("tel-extension", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::TelExtension, AutofillCategory::Contact });
+ map.get().add(AtomicString("email", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Email, AutofillCategory::Contact });
+ map.get().add(AtomicString("impp", AtomicString::ConstructFromLiteral), AutofillInfo{ AutofillFieldName::Impp, AutofillCategory::Contact });
+ }
+
+ return map;
+}
+
+AutofillFieldName toAutofillFieldName(const AtomicString& value)
+{
+ auto map = fieldNameMap();
+ auto it = map.find(value);
+ if (it == map.end())
+ return AutofillFieldName::None;
+ return it->value.fieldName;
+}
+
+static inline bool isContactToken(const AtomicString& token)
+{
+ static NeverDestroyed<AtomicString> home("home", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<AtomicString> work("work", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<AtomicString> mobile("mobile", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<AtomicString> fax("fax", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<AtomicString> pager("pager", AtomicString::ConstructFromLiteral);
+
+ return token == home || token == work || token == mobile || token == fax || token == pager;
+}
+
+static unsigned maxTokensForAutofillFieldCategory(AutofillCategory category)
+{
+ switch (category) {
+ 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
+AutofillData AutofillData::createFromHTMLFormControlElement(const HTMLFormControlElement& element)
+{
+ static NeverDestroyed<AtomicString> on("on", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<AtomicString> off("off", AtomicString::ConstructFromLiteral);
+
+ // Label: Default
+ // 26. Let the element's IDL-exposed autofill value be the empty string, and its autofill hint set and autofill scope be empty.
+ // 27. If the element's autocomplete attribute is wearing the autofill anchor mantle, then let the element's autofill field name be the empty string and abort these steps.
+ // 28. Let form be the element's form owner, if any, or null otherwise.
+ // 29. If form is not null and form's autocomplete attribute is in the off state, then let the element's autofill field name be "off". Otherwise, let the element's autofill field name be "on".
+ auto defaultLabel = [&] () -> AutofillData {
+ if (element.autofillMantle() == AutofillMantle::Anchor)
+ return { emptyString(), emptyString() };
+
+ auto form = element.form();
+ if (form && form->autocomplete() == off)
+ return { off, emptyString() };
+ return { on, emptyString() };
+ };
+
+
+ const AtomicString& attributeValue = element.fastGetAttribute(HTMLNames::autocompleteAttr);
+
+ // 1. If the element has no autocomplete attribute, then jump to the step labeled default.
+ if (attributeValue == nullAtom)
+ return defaultLabel();
+
+ // 2. Let tokens be the result of splitting the attribute's value on spaces.
+ SpaceSplitString tokens(attributeValue, true);
+
+ // 3. If tokens is empty, then jump to the step labeled default.
+ if (tokens.isEmpty())
+ return defaultLabel();
+
+ // 4. Let index be the index of the last token in tokens
+ unsigned index = tokens.size() - 1;
+
+ // 5. If the indexth token in tokens is not an ASCII case-insensitive match for one of the
+ // tokens given in the first column of the following table, or if the number of tokens in
+ // tokens is greater than the maximum number given in the cell in the second column of that
+ // token's row, then jump to the step labeled default. Otherwise, let field be the string given
+ // in the cell of the first column of the matching row, and let category be the value of the
+ // cell in the third column of that same row.
+ auto& map = fieldNameMap();
+
+ auto it = map.find(tokens[index]);
+ if (it == map.end())
+ return defaultLabel();
+
+ auto category = it->value.category;
+
+ if (tokens.size() > maxTokensForAutofillFieldCategory(category))
+ return defaultLabel();
+
+ const auto& field = tokens[index];
+
+ // 6. If category is Off or Automatic but the element's autocomplete attribute is wearing the
+ // autofill anchor mantle, then jump to the step labeled default.
+ auto mantle = element.autofillMantle();
+ if ((category == AutofillCategory::Off || category == AutofillCategory::Automatic) && mantle == AutofillMantle::Anchor)
+ return defaultLabel();
+
+ // 7. If category is Off, let the element's autofill field name be the string "off", let its
+ // autofill hint set be empty, and let its IDL-exposed autofill value be the string "off".
+ // Then, abort these steps.
+ if (category == AutofillCategory::Off)
+ return { off, off.get().string() };
+
+ // 8. If category is Automatic, let the element's autofill field name be the string "on",
+ // let its autofill hint set be empty, and let its IDL-exposed autofill value be the string
+ // "on". Then, abort these steps.
+ if (category == AutofillCategory::Off)
+ return { on, on.get().string() };
+
+ // 9. Let scope tokens be an empty list.
+ // 10. Let hint tokens be an empty set.
+
+ // NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
+
+ // 11. Let IDL value have the same value as field.
+ String idlValue = field;
+
+ // 12, If the indexth token in tokens is the first entry, then skip to the step labeled done.
+ if (index == 0)
+ return { field, idlValue };
+
+ // 13. Decrement index by one
+ index--;
+
+ // 14. If category is Contact and the indexth token in tokens is an ASCII case-insensitive match
+ // for one of the strings in the following list, then run the substeps that follow:
+ const auto& contactToken = tokens[index];
+ if (category == AutofillCategory::Contact && isContactToken(contactToken)) {
+ // 1. Let contact be the matching string from the list above.
+ const auto& contact = contactToken;
+
+ // 2. Insert contact at the start of scope tokens.
+ // 3. Add contact to hint tokens.
+
+ // NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
+
+ // 4. Let IDL value be the concatenation of contact, a U+0020 SPACE character, and the previous
+ // value of IDL value (which at this point will always be field).
+ idlValue = WTF::makeString(contact, " ", idlValue);
+
+ // 5. If the indexth entry in tokens is the first entry, then skip to the step labeled done.
+ if (index == 0)
+ return { field, idlValue };
+
+ // 6. Decrement index by one.
+ index--;
+ }
+
+ // 15. If the indexth token in tokens is an ASCII case-insensitive match for one of the strings
+ // in the following list, then run the substeps that follow:
+ const auto& modeToken = tokens[index];
+ if (equalIgnoringASCIICase(modeToken, "shipping") || equalIgnoringASCIICase(modeToken, "billing")) {
+ // 1. Let mode be the matching string from the list above.
+ const auto& mode = modeToken;
+
+ // 2. Insert mode at the start of scope tokens.
+ // 3. Add mode to hint tokens.
+
+ // NOTE: We are ignoring these steps as we don't currently make use of scope tokens or hint tokens anywhere.
+
+ // 4. Let IDL value be the concatenation of mode, a U+0020 SPACE character, and the previous
+ // value of IDL value (which at this point will either be field or the concatenation of contact,
+ // a space, and field).
+ idlValue = WTF::makeString(mode, " ", idlValue);
+
+ // 5. If the indexth entry in tokens is the first entry, then skip to the step labeled done.
+ if (index == 0)
+ return { field, idlValue };
+
+ // 6. Decrement index by one.
+ index--;
+ }
+
+ // 16. If the indexth entry in tokens is not the first entry, then jump to the step labeled default.
+ if (index != 0)
+ return defaultLabel();
+
+ // 17. If the first eight characters of the indexth token in tokens are not an ASCII case-insensitive
+ // match for the string "section-", then jump to the step labeled default.
+ const auto& sectionToken = tokens[index];
+ if (!sectionToken.startsWithIgnoringASCIICase("section-"))
+ return defaultLabel();
+
+ // 18. Let section be the indexth token in tokens, converted to ASCII lowercase.
+ const auto& section = sectionToken;
+
+ // 19. Insert section at the start of scope tokens.
+
+ // NOTE: We are ignoring this step as we don't currently make use of scope tokens or hint tokens anywhere.
+
+ // 20. Let IDL value be the concatenation of section, a U+0020 SPACE character, and the previous
+ // value of IDL value.
+ idlValue = WTF::makeString(section, " ", idlValue);
+
+ return { field, idlValue };
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlAutofillh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/html/Autofill.h (0 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/Autofill.h         (rev 0)
+++ trunk/Source/WebCore/html/Autofill.h        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -0,0 +1,118 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef Autofill_h
+#define Autofill_h
+
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+enum class AutofillMantle {
+ Expectation,
+ Anchor
+};
+
+enum class AutofillFieldName {
+ None,
+ Name,
+ HonorificPrefix,
+ GivenName,
+ AdditionalName,
+ FamilyName,
+ HonorificSuffix,
+ Nickname,
+ Username,
+ NewPassword,
+ CurrentPassword,
+ OrganizationTitle,
+ Organization,
+ StreetAddress,
+ AddressLine1,
+ AddressLine2,
+ AddressLine3,
+ AddressLevel4,
+ AddressLevel3,
+ AddressLevel2,
+ AddressLevel1,
+ Country,
+ CountryName,
+ PostalCode,
+ CcName,
+ CcGivenName,
+ CcAdditionalName,
+ CcFamilyName,
+ CcNumber,
+ CcExp,
+ CcExpMonth,
+ CcExpYear,
+ CcCsc,
+ CcType,
+ TransactionCurrency,
+ TransactionAmount,
+ Language,
+ Bday,
+ BdayDay,
+ BdayMonth,
+ BdayYear,
+ Sex,
+ URL,
+ Photo,
+ Tel,
+ TelCountryCode,
+ TelNational,
+ TelAreaCode,
+ TelLocal,
+ TelLocalPrefix,
+ TelLocalSuffix,
+ TelExtension,
+ Email,
+ Impp
+};
+
+WEBCORE_EXPORT AutofillFieldName toAutofillFieldName(const AtomicString&);
+
+class HTMLFormControlElement;
+
+class AutofillData {
+public:
+ static AutofillData createFromHTMLFormControlElement(const HTMLFormControlElement&);
+
+ AutofillData(const AtomicString& fieldName, const String& idlExposedValue)
+ : fieldName(fieldName)
+ , idlExposedValue(idlExposedValue)
+ {
+ }
+
+ // We could add support for hint tokens and scope tokens if those ever became useful to anyone.
+
+ AtomicString fieldName;
+ String idlExposedValue;
+};
+
+} // namespace
+
+#endif // Autofill_h
</ins></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -25,6 +25,7 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "HTMLFormControlElement.h"
</span><span class="cx">
</span><ins>+#include "Autofill.h"
</ins><span class="cx"> #include "ControlStates.h"
</span><span class="cx"> #include "ElementAncestorIterator.h"
</span><span class="cx"> #include "Event.h"
</span><span class="lines">@@ -611,167 +612,28 @@
</span><span class="cx"> return nullptr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline bool isContactToken(const AtomicString& token)
</del><ins>+String HTMLFormControlElement::autocomplete() const
</ins><span class="cx"> {
</span><del>- return token == "home" || token == "work" || token == "mobile" || token == "fax" || token == "pager";
</del><ins>+ return autofillData().idlExposedValue;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-enum class AutofillCategory {
- Invalid,
- Off,
- Automatic,
- Normal,
- Contact,
-};
-
-static inline AutofillCategory categoryForAutofillFieldToken(const AtomicString& token)
</del><ins>+void HTMLFormControlElement::setAutocomplete(const String& value)
</ins><span class="cx"> {
</span><del>- 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);
</del><ins>+ setAttribute(autocompleteAttr, value);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static inline unsigned maxTokensForAutofillFieldCategory(AutofillCategory category)
</del><ins>+AutofillMantle HTMLFormControlElement::autofillMantle() const
</ins><span class="cx"> {
</span><del>- 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;
</del><ins>+ return is<HTMLInputElement>(*this) && downcast<HTMLInputElement>(this)->isInputTypeHidden() ? AutofillMantle::Anchor : AutofillMantle::Expectation;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-// https://html.spec.whatwg.org/multipage/forms.html#processing-model-3
-String HTMLFormControlElement::autocomplete() const
</del><ins>+AutofillData HTMLFormControlElement::autofillData() const
</ins><span class="cx"> {
</span><del>- bool wearingAutofillAnchorMantle = is<HTMLInputElement>(*this) && downcast<HTMLInputElement>(this)->isInputTypeHidden();
</del><ins>+ // FIXME: We could cache the AutofillData if we we had an efficient way to invalidate the cache when
+ // the autofill mantle changed (due to a type change on an <input> element) or the element's form
+ // owner's autocomplete attribute changed or the form owner itself changed.
</ins><span class="cx">
</span><del>- const AtomicString& attributeValue = fastGetAttribute(autocompleteAttr);
- SpaceSplitString tokens(attributeValue, true);
- if (tokens.isEmpty()) {
- if (wearingAutofillAnchorMantle)
- return String();
- return form() ? form()->autocomplete() : ASCIILiteral("on");
- }
-
- 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();
-
- 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;
</del><ins>+ return AutofillData::createFromHTMLFormControlElement(*this);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void HTMLFormControlElement::setAutocomplete(const String& value)
-{
- setAttribute(autocompleteAttr, value);
-}
-
</del><span class="cx"> } // namespace Webcore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormControlElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormControlElement.h        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -24,6 +24,7 @@
</span><span class="cx"> #ifndef HTMLFormControlElement_h
</span><span class="cx"> #define HTMLFormControlElement_h
</span><span class="cx">
</span><ins>+#include "Autofill.h"
</ins><span class="cx"> #include "FormAssociatedElement.h"
</span><span class="cx"> #include "LabelableElement.h"
</span><span class="cx">
</span><span class="lines">@@ -120,6 +121,10 @@
</span><span class="cx"> String autocomplete() const;
</span><span class="cx"> void setAutocomplete(const String&);
</span><span class="cx">
</span><ins>+ AutofillMantle autofillMantle() const;
+
+ WEBCORE_EXPORT AutofillData autofillData() const;
+
</ins><span class="cx"> using Node::ref;
</span><span class="cx"> using Node::deref;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormElement.cpp (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormElement.cpp        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/html/HTMLFormElement.cpp        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -865,10 +865,10 @@
</span><span class="cx"> setAttributeWithoutSynchronization(autocompleteAttr, value);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-const String& HTMLFormElement::autocomplete() const
</del><ins>+const AtomicString& HTMLFormElement::autocomplete() const
</ins><span class="cx"> {
</span><del>- static NeverDestroyed<const String> on("on", String::ConstructFromLiteral);
- static NeverDestroyed<const String> off("off", String::ConstructFromLiteral);
</del><ins>+ static NeverDestroyed<AtomicString> on("on", AtomicString::ConstructFromLiteral);
+ static NeverDestroyed<AtomicString> off("off", AtomicString::ConstructFromLiteral);
</ins><span class="cx">
</span><span class="cx"> return equalIgnoringASCIICase(fastGetAttribute(autocompleteAttr), "off") ? off : on;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLFormElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLFormElement.h (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLFormElement.h        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/html/HTMLFormElement.h        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> bool shouldAutocomplete() const;
</span><span class="cx">
</span><span class="cx"> void setAutocomplete(const AtomicString&);
</span><del>- const String& autocomplete() const;
</del><ins>+ const AtomicString& autocomplete() const;
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(IOS_AUTOCORRECT_AND_AUTOCAPITALIZE)
</span><span class="cx"> WEBCORE_EXPORT bool autocorrect() const;
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/testing/Internals.cpp        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "ActiveDOMCallbackMicrotask.h"
</span><span class="cx"> #include "AnimationController.h"
</span><span class="cx"> #include "ApplicationCacheStorage.h"
</span><ins>+#include "Autofill.h"
</ins><span class="cx"> #include "BackForwardController.h"
</span><span class="cx"> #include "BitmapImage.h"
</span><span class="cx"> #include "CachedImage.h"
</span><span class="lines">@@ -1369,6 +1370,21 @@
</span><span class="cx"> frameView->scrollElementToRect(*element, IntRect(x, y, w, h));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+String Internals::autofillFieldName(Element* element, ExceptionCode& ec)
+{
+ if (!element) {
+ ec = INVALID_ACCESS_ERR;
+ return { };
+ }
+
+ if (!is<HTMLFormControlElement>(*element)) {
+ ec = INVALID_NODE_TYPE_ERR;
+ return { };
+ }
+
+ return downcast<HTMLFormControlElement>(*element).autofillData().fieldName;
+}
+
</ins><span class="cx"> void Internals::paintControlTints(ExceptionCode& ec)
</span><span class="cx"> {
</span><span class="cx"> Document* document = contextDocument();
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/testing/Internals.h        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -183,6 +183,8 @@
</span><span class="cx"> void setShowAutoFillButton(Element*, const String& autoFillButtonType, ExceptionCode&);
</span><span class="cx"> void scrollElementToRect(Element*, long x, long y, long w, long h, ExceptionCode&);
</span><span class="cx">
</span><ins>+ String autofillFieldName(Element*, ExceptionCode&);
+
</ins><span class="cx"> void paintControlTints(ExceptionCode&);
</span><span class="cx">
</span><span class="cx"> RefPtr<Range> rangeFromLocationAndLength(Element* scope, int rangeLocation, int rangeLength, ExceptionCode&);
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebCore/testing/Internals.idl        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -162,6 +162,8 @@
</span><span class="cx"> [RaisesException] void setShowAutoFillButton(Element inputElement, AutoFillButtonType autoFillButtonType);
</span><span class="cx"> [RaisesException] unsigned long countMatchesForText(DOMString text, unsigned long findOptions, DOMString markMatches);
</span><span class="cx">
</span><ins>+ [RaisesException] DOMString autofillFieldName(Element formControlElement);
+
</ins><span class="cx"> [RaisesException] void paintControlTints();
</span><span class="cx">
</span><span class="cx"> [RaisesException] void scrollElementToRect(Element element, long x, long y, long w, long h);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -1,3 +1,26 @@
</span><ins>+2016-03-05 Sam Weinig <sam@webkit.org>
+
+ Add support for processing the autofill field name out of form control elements ultimately to aid input methods
+ <rdar://problem/23041180>
+ https://bugs.webkit.org/show_bug.cgi?id=155079
+
+ Reviewed by Enrica Casucci.
+
+ * Shared/AssistedNodeInformation.cpp:
+ (WebKit::AssistedNodeInformation::encode):
+ (WebKit::AssistedNodeInformation::decode):
+ * Shared/AssistedNodeInformation.h:
+ Add AutofillFieldName. Convert some coders to use encodeEnum/decodeEnum instead of casting.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView textInputTraits]):
+ Map AutofillFieldNames to the associated UITextContentTypes.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getAssistedNodeInformation):
+ Extract the AutofillFieldNames onto the AssistedNodeInformation for <input> elements
+ and <textarea> elements.
+
</ins><span class="cx"> 2016-03-05 Timothy Hatcher <timothy@apple.com>
</span><span class="cx">
</span><span class="cx"> Implement the Automation protocol commands by tracking WebPageProxy objects
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAssistedNodeInformationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebKit2/Shared/AssistedNodeInformation.cpp        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -71,8 +71,8 @@
</span><span class="cx"> encoder << hasNextNode;
</span><span class="cx"> encoder << hasPreviousNode;
</span><span class="cx"> encoder << isAutocorrect;
</span><del>- encoder << (uint32_t)autocapitalizeType;
- encoder << (uint32_t)elementType;
</del><ins>+ encoder.encodeEnum(autocapitalizeType);
+ encoder.encodeEnum(elementType);
</ins><span class="cx"> encoder << formAction;
</span><span class="cx"> encoder << selectOptions;
</span><span class="cx"> encoder << selectedIndex;
</span><span class="lines">@@ -83,6 +83,7 @@
</span><span class="cx"> encoder << value;
</span><span class="cx"> encoder << valueAsNumber;
</span><span class="cx"> encoder << title;
</span><ins>+ encoder.encodeEnum(autofillFieldName);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool AssistedNodeInformation::decode(IPC::ArgumentDecoder& decoder, AssistedNodeInformation& result)
</span><span class="lines">@@ -111,10 +112,10 @@
</span><span class="cx"> if (!decoder.decode(result.isAutocorrect))
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (!decoder.decode((uint32_t&)result.autocapitalizeType))
</del><ins>+ if (!decoder.decodeEnum(result.autocapitalizeType))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (!decoder.decode((uint32_t&)result.elementType))
</del><ins>+ if (!decoder.decodeEnum(result.elementType))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> if (!decoder.decode(result.formAction))
</span><span class="lines">@@ -147,6 +148,9 @@
</span><span class="cx"> if (!decoder.decode(result.title))
</span><span class="cx"> return false;
</span><span class="cx">
</span><ins>+ if (!decoder.decodeEnum(result.autofillFieldName))
+ return false;
+
</ins><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedAssistedNodeInformationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/AssistedNodeInformation.h (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/AssistedNodeInformation.h        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebKit2/Shared/AssistedNodeInformation.h        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define AssistedNodeInformation_h
</span><span class="cx">
</span><span class="cx"> #include "ArgumentCoders.h"
</span><ins>+#include <WebCore/Autofill.h>
</ins><span class="cx"> #include <WebCore/IntRect.h>
</span><span class="cx"> #include <WebCore/WebAutocapitalize.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="lines">@@ -130,6 +131,7 @@
</span><span class="cx"> String value;
</span><span class="cx"> double valueAsNumber;
</span><span class="cx"> String title;
</span><ins>+ WebCore::AutofillFieldName autofillFieldName { WebCore::AutofillFieldName::None };
</ins><span class="cx">
</span><span class="cx"> void encode(IPC::ArgumentEncoder&) const;
</span><span class="cx"> static bool decode(IPC::ArgumentDecoder&, AssistedNodeInformation&);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -2822,6 +2822,106 @@
</span><span class="cx"> [_traits setKeyboardType:UIKeyboardTypeDefault];
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
+ switch (_assistedNodeInformation.autofillFieldName) {
+ case WebCore::AutofillFieldName::Name:
+ [_traits setTextContentType:UITextContentTypeName];
+ break;
+ case WebCore::AutofillFieldName::HonorificPrefix:
+ [_traits setTextContentType:UITextContentTypeNamePrefix];
+ break;
+ case WebCore::AutofillFieldName::GivenName:
+ [_traits setTextContentType:UITextContentTypeMiddleName];
+ break;
+ case WebCore::AutofillFieldName::AdditionalName:
+ [_traits setTextContentType:UITextContentTypeMiddleName];
+ break;
+ case WebCore::AutofillFieldName::FamilyName:
+ [_traits setTextContentType:UITextContentTypeFamilyName];
+ break;
+ case WebCore::AutofillFieldName::HonorificSuffix:
+ [_traits setTextContentType:UITextContentTypeNameSuffix];
+ break;
+ case WebCore::AutofillFieldName::Nickname:
+ [_traits setTextContentType:UITextContentTypeNickname];
+ break;
+ case WebCore::AutofillFieldName::OrganizationTitle:
+ [_traits setTextContentType:UITextContentTypeJobTitle];
+ break;
+ case WebCore::AutofillFieldName::Organization:
+ [_traits setTextContentType:UITextContentTypeOrganizationName];
+ break;
+ case WebCore::AutofillFieldName::StreetAddress:
+ [_traits setTextContentType:UITextContentTypeFullStreetAddress];
+ break;
+ case WebCore::AutofillFieldName::AddressLine1:
+ [_traits setTextContentType:UITextContentTypeStreetAddressLine1];
+ break;
+ case WebCore::AutofillFieldName::AddressLine2:
+ [_traits setTextContentType:UITextContentTypeStreetAddressLine2];
+ break;
+ case WebCore::AutofillFieldName::AddressLevel3:
+ [_traits setTextContentType:UITextContentTypeSublocality];
+ break;
+ case WebCore::AutofillFieldName::AddressLevel2:
+ [_traits setTextContentType:UITextContentTypeAddressCity];
+ break;
+ case WebCore::AutofillFieldName::AddressLevel1:
+ [_traits setTextContentType:UITextContentTypeAddressState];
+ break;
+ case WebCore::AutofillFieldName::CountryName:
+ [_traits setTextContentType:UITextContentTypeCountryName];
+ break;
+ case WebCore::AutofillFieldName::PostalCode:
+ [_traits setTextContentType:UITextContentTypePostalCode];
+ break;
+ case WebCore::AutofillFieldName::Tel:
+ [_traits setTextContentType:UITextContentTypeTelephoneNumber];
+ break;
+ case WebCore::AutofillFieldName::Email:
+ [_traits setTextContentType:UITextContentTypeEmailAddress];
+ break;
+ case WebCore::AutofillFieldName::URL:
+ [_traits setTextContentType:UITextContentTypeURL];
+ break;
+ case WebCore::AutofillFieldName::None:
+ case WebCore::AutofillFieldName::Username:
+ case WebCore::AutofillFieldName::NewPassword:
+ case WebCore::AutofillFieldName::CurrentPassword:
+ case WebCore::AutofillFieldName::AddressLine3:
+ case WebCore::AutofillFieldName::AddressLevel4:
+ case WebCore::AutofillFieldName::Country:
+ case WebCore::AutofillFieldName::CcName:
+ case WebCore::AutofillFieldName::CcGivenName:
+ case WebCore::AutofillFieldName::CcAdditionalName:
+ case WebCore::AutofillFieldName::CcFamilyName:
+ case WebCore::AutofillFieldName::CcNumber:
+ case WebCore::AutofillFieldName::CcExp:
+ case WebCore::AutofillFieldName::CcExpMonth:
+ case WebCore::AutofillFieldName::CcExpYear:
+ case WebCore::AutofillFieldName::CcCsc:
+ case WebCore::AutofillFieldName::CcType:
+ case WebCore::AutofillFieldName::TransactionCurrency:
+ case WebCore::AutofillFieldName::TransactionAmount:
+ case WebCore::AutofillFieldName::Language:
+ case WebCore::AutofillFieldName::Bday:
+ case WebCore::AutofillFieldName::BdayDay:
+ case WebCore::AutofillFieldName::BdayMonth:
+ case WebCore::AutofillFieldName::BdayYear:
+ case WebCore::AutofillFieldName::Sex:
+ case WebCore::AutofillFieldName::Photo:
+ case WebCore::AutofillFieldName::TelCountryCode:
+ case WebCore::AutofillFieldName::TelNational:
+ case WebCore::AutofillFieldName::TelAreaCode:
+ case WebCore::AutofillFieldName::TelLocal:
+ case WebCore::AutofillFieldName::TelLocalPrefix:
+ case WebCore::AutofillFieldName::TelLocalSuffix:
+ case WebCore::AutofillFieldName::TelExtension:
+ case WebCore::AutofillFieldName::Impp:
+ break;
+ };
+#endif
+
</ins><span class="cx"> return _traits.get();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (197625 => 197626)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2016-03-06 01:52:38 UTC (rev 197625)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2016-03-06 02:17:29 UTC (rev 197626)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> #import "WebPageProxyMessages.h"
</span><span class="cx"> #import "WebProcess.h"
</span><span class="cx"> #import <CoreText/CTFont.h>
</span><ins>+#import <WebCore/Autofill.h>
</ins><span class="cx"> #import <WebCore/Chrome.h>
</span><span class="cx"> #import <WebCore/DataDetection.h>
</span><span class="cx"> #import <WebCore/DiagnosticLoggingClient.h>
</span><span class="lines">@@ -2425,6 +2426,7 @@
</span><span class="cx"> information.elementType = InputType::TextArea;
</span><span class="cx"> information.isReadOnly = element.isReadOnly();
</span><span class="cx"> information.value = element.value();
</span><ins>+ information.autofillFieldName = WebCore::toAutofillFieldName(element.autofillData().fieldName);
</ins><span class="cx"> } else if (is<HTMLInputElement>(*m_assistedNode)) {
</span><span class="cx"> HTMLInputElement& element = downcast<HTMLInputElement>(*m_assistedNode);
</span><span class="cx"> HTMLFormElement* form = element.form();
</span><span class="lines">@@ -2472,6 +2474,7 @@
</span><span class="cx"> information.value = element.value();
</span><span class="cx"> information.valueAsNumber = element.valueAsNumber();
</span><span class="cx"> information.title = element.title();
</span><ins>+ information.autofillFieldName = WebCore::toAutofillFieldName(element.autofillData().fieldName);
</ins><span class="cx"> } else if (m_assistedNode->hasEditableStyle()) {
</span><span class="cx"> information.elementType = InputType::ContentEditable;
</span><span class="cx"> information.isAutocorrect = true; // FIXME: Should we look at the attribute?
</span></span></pre>
</div>
</div>
</body>
</html>