haikuwebkit/Source/WebCore/html/Autofill.h

181 lines
5.6 KiB
C
Raw Permalink Normal View History

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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
/*
[IPC] Add WTF::EnumTraits<> for every enum type used in IPC <https://webkit.org/b/213093> Reviewed by Darin Adler. Summary: - Change underlying type of enum class to `bool` when there are only two values. In some cases, reorder the two values so the mapping to 0 and 1 makes more sense. Converting every enum to an enum class is not a goal of this patch, so some two-value enums stil have WTF::EnumTraits<> defined as noted below. - Add WTF::EnumTraits<> for the remaining enum types that are used by IPC::Encoder::encodeEnum() and IPC::Decoder::decodeEnum() so that WTF::isValidEnum<>() checks may be added next. - Add #include <WebCore/LibWebRTCEnumTraits.h> as needed. Source/WebCore: * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: - Add LibWebRTCEnumTraits.h to project. Keep these definitions separate from the libwebrtc project cut down on changes to re-merge after updating. * platform/mediastream/libwebrtc/LibWebRTCEnumTraits.h: Add. * Modules/applepay/ApplePaySessionPaymentRequest.h: * Modules/indexeddb/IDBTransactionMode.h: * Modules/indexeddb/IndexedDB.h: (WTF::EnumTraits<WebCore::IndexedDB::IndexRecordType>): - Remove after changing enum class to bool. * Modules/indexeddb/shared/IDBGetRecordData.h: * Modules/indexeddb/shared/IDBResultData.h: * WebCore.xcodeproj/project.pbxproj: * dom/ExceptionCode.h: * editing/CompositionUnderline.h: * html/Autofill.h: * html/DataListSuggestionInformation.h: * html/EnterKeyHint.h: * html/LinkIconType.h: * loader/FrameLoaderTypes.h: - Alphabetize WTF::EnumTraits<> definitions. * loader/ResourceLoaderOptions.h: * page/SecurityOrigin.h: * page/UserStyleSheetTypes.h: (WTF::EnumTraits<WebCore::UserStyleLevel>): - Define this since UserStyleLevel is not an enum class. * page/scrolling/ScrollingCoordinatorTypes.h: * platform/ContextMenuItem.h: * platform/Cursor.h: * platform/DragData.h: * platform/FileChooser.h: * platform/PopupMenuStyle.h: * platform/ScreenProperties.h: * platform/ScrollTypes.h: * platform/SerializedPlatformDataCueValue.h: (WebCore::SerializedPlatformDataCueValue::PlatformType): - Convert from enum to enum class. * platform/UserInterfaceLayoutDirection.h: * platform/animation/TimingFunction.h: * platform/graphics/GraphicsContext.h: * platform/graphics/GraphicsLayer.h: * platform/graphics/GraphicsTypes.h: - Alphabetize WTF::EnumTraits<> definitions. * platform/graphics/Image.h: * platform/graphics/Path.h: * platform/graphics/ca/PlatformCAAnimation.h: * platform/graphics/ca/PlatformCALayer.h: * platform/graphics/filters/FilterOperation.h: * platform/mediastream/MediaConstraints.h: * platform/mediastream/MediaStreamRequest.h: (WTF::EnumTraits<WebCore::MediaStreamRequest::Type>): - Fix EnumTraits definition (missing "::Type"). * platform/mediastream/RealtimeMediaSourceCapabilities.h: * platform/mediastream/RealtimeMediaSourceSupportedConstraints.h: * platform/network/CredentialBase.h: * platform/network/ProtectionSpaceBase.h: * platform/network/ResourceErrorBase.h: * platform/network/soup/SoupNetworkProxySettings.h: * platform/text/TextChecking.h: (WTF::EnumTraits<WebCore::TextCheckingProcessType): - Define this since TextCheckingProcessType is not an enum class. * platform/text/WritingMode.h: * rendering/Pagination.h: * workers/service/ServiceWorkerJobType.h: Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.h: * GPUProcess/GPUProcess.h: * NetworkProcess/NetworkLoadParameters.h: * Shared/API/APIObject.h: * Shared/ContextMenuContextData.h: * Shared/DrawingAreaInfo.h: * Shared/FocusedElementInformation.h: * Shared/PrintInfo.h: (WTF::EnumTraits<WebKit::PrintInfo::PrintMode>): - Define this since PrintMode is not an enum class. * Shared/RTCPacketOptions.cpp: * Shared/SessionState.h: * Shared/TouchBarMenuItemData.h: * Shared/WebEvent.h: * Shared/WebPopupItem.cpp: (WebKit::WebPopupItem::WebPopupItem): - Fix reference to WebPopupItem::Type enum. * Shared/WebPopupItem.h: (WebKit::WebPopupItem::Type): - Convert from enum to enum class. * Shared/WebsiteData/WebsiteDataType.h: * Shared/glib/InputMethodState.h: * Shared/glib/UserMessage.h: * Shared/mac/ColorSpaceData.mm: * Shared/mac/SecItemRequestData.h: * UIProcess/mac/WebPopupMenuProxyMac.mm: (WebKit::WebPopupMenuProxyMac::populate): - Fix reference to WebPopupItem::Type enum. * WebProcess/Plugins/Plugin.cpp: * WebProcess/WebCoreSupport/WebPopupMenu.cpp: (WebKit::WebPopupMenu::populateItems): - Fix reference to WebPopupItem::Type enum. * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h: Canonical link: https://commits.webkit.org/225887@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-12 06:02:42 +00:00
* Copyright (C) 2016-2020 Apple Inc. All rights reserved.
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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
*
* 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.
*/
#pragma once
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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
[IPC] Add WTF::EnumTraits<> for every enum type used in IPC <https://webkit.org/b/213093> Reviewed by Darin Adler. Summary: - Change underlying type of enum class to `bool` when there are only two values. In some cases, reorder the two values so the mapping to 0 and 1 makes more sense. Converting every enum to an enum class is not a goal of this patch, so some two-value enums stil have WTF::EnumTraits<> defined as noted below. - Add WTF::EnumTraits<> for the remaining enum types that are used by IPC::Encoder::encodeEnum() and IPC::Decoder::decodeEnum() so that WTF::isValidEnum<>() checks may be added next. - Add #include <WebCore/LibWebRTCEnumTraits.h> as needed. Source/WebCore: * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: - Add LibWebRTCEnumTraits.h to project. Keep these definitions separate from the libwebrtc project cut down on changes to re-merge after updating. * platform/mediastream/libwebrtc/LibWebRTCEnumTraits.h: Add. * Modules/applepay/ApplePaySessionPaymentRequest.h: * Modules/indexeddb/IDBTransactionMode.h: * Modules/indexeddb/IndexedDB.h: (WTF::EnumTraits<WebCore::IndexedDB::IndexRecordType>): - Remove after changing enum class to bool. * Modules/indexeddb/shared/IDBGetRecordData.h: * Modules/indexeddb/shared/IDBResultData.h: * WebCore.xcodeproj/project.pbxproj: * dom/ExceptionCode.h: * editing/CompositionUnderline.h: * html/Autofill.h: * html/DataListSuggestionInformation.h: * html/EnterKeyHint.h: * html/LinkIconType.h: * loader/FrameLoaderTypes.h: - Alphabetize WTF::EnumTraits<> definitions. * loader/ResourceLoaderOptions.h: * page/SecurityOrigin.h: * page/UserStyleSheetTypes.h: (WTF::EnumTraits<WebCore::UserStyleLevel>): - Define this since UserStyleLevel is not an enum class. * page/scrolling/ScrollingCoordinatorTypes.h: * platform/ContextMenuItem.h: * platform/Cursor.h: * platform/DragData.h: * platform/FileChooser.h: * platform/PopupMenuStyle.h: * platform/ScreenProperties.h: * platform/ScrollTypes.h: * platform/SerializedPlatformDataCueValue.h: (WebCore::SerializedPlatformDataCueValue::PlatformType): - Convert from enum to enum class. * platform/UserInterfaceLayoutDirection.h: * platform/animation/TimingFunction.h: * platform/graphics/GraphicsContext.h: * platform/graphics/GraphicsLayer.h: * platform/graphics/GraphicsTypes.h: - Alphabetize WTF::EnumTraits<> definitions. * platform/graphics/Image.h: * platform/graphics/Path.h: * platform/graphics/ca/PlatformCAAnimation.h: * platform/graphics/ca/PlatformCALayer.h: * platform/graphics/filters/FilterOperation.h: * platform/mediastream/MediaConstraints.h: * platform/mediastream/MediaStreamRequest.h: (WTF::EnumTraits<WebCore::MediaStreamRequest::Type>): - Fix EnumTraits definition (missing "::Type"). * platform/mediastream/RealtimeMediaSourceCapabilities.h: * platform/mediastream/RealtimeMediaSourceSupportedConstraints.h: * platform/network/CredentialBase.h: * platform/network/ProtectionSpaceBase.h: * platform/network/ResourceErrorBase.h: * platform/network/soup/SoupNetworkProxySettings.h: * platform/text/TextChecking.h: (WTF::EnumTraits<WebCore::TextCheckingProcessType): - Define this since TextCheckingProcessType is not an enum class. * platform/text/WritingMode.h: * rendering/Pagination.h: * workers/service/ServiceWorkerJobType.h: Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.h: * GPUProcess/GPUProcess.h: * NetworkProcess/NetworkLoadParameters.h: * Shared/API/APIObject.h: * Shared/ContextMenuContextData.h: * Shared/DrawingAreaInfo.h: * Shared/FocusedElementInformation.h: * Shared/PrintInfo.h: (WTF::EnumTraits<WebKit::PrintInfo::PrintMode>): - Define this since PrintMode is not an enum class. * Shared/RTCPacketOptions.cpp: * Shared/SessionState.h: * Shared/TouchBarMenuItemData.h: * Shared/WebEvent.h: * Shared/WebPopupItem.cpp: (WebKit::WebPopupItem::WebPopupItem): - Fix reference to WebPopupItem::Type enum. * Shared/WebPopupItem.h: (WebKit::WebPopupItem::Type): - Convert from enum to enum class. * Shared/WebsiteData/WebsiteDataType.h: * Shared/glib/InputMethodState.h: * Shared/glib/UserMessage.h: * Shared/mac/ColorSpaceData.mm: * Shared/mac/SecItemRequestData.h: * UIProcess/mac/WebPopupMenuProxyMac.mm: (WebKit::WebPopupMenuProxyMac::populate): - Fix reference to WebPopupItem::Type enum. * WebProcess/Plugins/Plugin.cpp: * WebProcess/WebCoreSupport/WebPopupMenu.cpp: (WebKit::WebPopupMenu::populateItems): - Fix reference to WebPopupItem::Type enum. * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h: Canonical link: https://commits.webkit.org/225887@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-12 06:02:42 +00:00
#include <wtf/EnumTraits.h>
#include <wtf/text/AtomString.h>
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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
#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 AtomString&);
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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
class HTMLFormControlElement;
class AutofillData {
public:
static AutofillData createFromHTMLFormControlElement(const HTMLFormControlElement&);
AutofillData(const AtomString& fieldName, const String& idlExposedValue)
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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
: fieldName(fieldName)
, idlExposedValue(idlExposedValue)
{
}
// We could add support for hint tokens and scope tokens if those ever became useful to anyone.
AtomString fieldName;
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. Canonical link: https://commits.webkit.org/173160@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@197626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-03-06 02:17:29 +00:00
String idlExposedValue;
};
} // namespace WebCore
[IPC] Add WTF::EnumTraits<> for every enum type used in IPC <https://webkit.org/b/213093> Reviewed by Darin Adler. Summary: - Change underlying type of enum class to `bool` when there are only two values. In some cases, reorder the two values so the mapping to 0 and 1 makes more sense. Converting every enum to an enum class is not a goal of this patch, so some two-value enums stil have WTF::EnumTraits<> defined as noted below. - Add WTF::EnumTraits<> for the remaining enum types that are used by IPC::Encoder::encodeEnum() and IPC::Decoder::decodeEnum() so that WTF::isValidEnum<>() checks may be added next. - Add #include <WebCore/LibWebRTCEnumTraits.h> as needed. Source/WebCore: * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: - Add LibWebRTCEnumTraits.h to project. Keep these definitions separate from the libwebrtc project cut down on changes to re-merge after updating. * platform/mediastream/libwebrtc/LibWebRTCEnumTraits.h: Add. * Modules/applepay/ApplePaySessionPaymentRequest.h: * Modules/indexeddb/IDBTransactionMode.h: * Modules/indexeddb/IndexedDB.h: (WTF::EnumTraits<WebCore::IndexedDB::IndexRecordType>): - Remove after changing enum class to bool. * Modules/indexeddb/shared/IDBGetRecordData.h: * Modules/indexeddb/shared/IDBResultData.h: * WebCore.xcodeproj/project.pbxproj: * dom/ExceptionCode.h: * editing/CompositionUnderline.h: * html/Autofill.h: * html/DataListSuggestionInformation.h: * html/EnterKeyHint.h: * html/LinkIconType.h: * loader/FrameLoaderTypes.h: - Alphabetize WTF::EnumTraits<> definitions. * loader/ResourceLoaderOptions.h: * page/SecurityOrigin.h: * page/UserStyleSheetTypes.h: (WTF::EnumTraits<WebCore::UserStyleLevel>): - Define this since UserStyleLevel is not an enum class. * page/scrolling/ScrollingCoordinatorTypes.h: * platform/ContextMenuItem.h: * platform/Cursor.h: * platform/DragData.h: * platform/FileChooser.h: * platform/PopupMenuStyle.h: * platform/ScreenProperties.h: * platform/ScrollTypes.h: * platform/SerializedPlatformDataCueValue.h: (WebCore::SerializedPlatformDataCueValue::PlatformType): - Convert from enum to enum class. * platform/UserInterfaceLayoutDirection.h: * platform/animation/TimingFunction.h: * platform/graphics/GraphicsContext.h: * platform/graphics/GraphicsLayer.h: * platform/graphics/GraphicsTypes.h: - Alphabetize WTF::EnumTraits<> definitions. * platform/graphics/Image.h: * platform/graphics/Path.h: * platform/graphics/ca/PlatformCAAnimation.h: * platform/graphics/ca/PlatformCALayer.h: * platform/graphics/filters/FilterOperation.h: * platform/mediastream/MediaConstraints.h: * platform/mediastream/MediaStreamRequest.h: (WTF::EnumTraits<WebCore::MediaStreamRequest::Type>): - Fix EnumTraits definition (missing "::Type"). * platform/mediastream/RealtimeMediaSourceCapabilities.h: * platform/mediastream/RealtimeMediaSourceSupportedConstraints.h: * platform/network/CredentialBase.h: * platform/network/ProtectionSpaceBase.h: * platform/network/ResourceErrorBase.h: * platform/network/soup/SoupNetworkProxySettings.h: * platform/text/TextChecking.h: (WTF::EnumTraits<WebCore::TextCheckingProcessType): - Define this since TextCheckingProcessType is not an enum class. * platform/text/WritingMode.h: * rendering/Pagination.h: * workers/service/ServiceWorkerJobType.h: Source/WebKit: * GPUProcess/GPUConnectionToWebProcess.h: * GPUProcess/GPUProcess.h: * NetworkProcess/NetworkLoadParameters.h: * Shared/API/APIObject.h: * Shared/ContextMenuContextData.h: * Shared/DrawingAreaInfo.h: * Shared/FocusedElementInformation.h: * Shared/PrintInfo.h: (WTF::EnumTraits<WebKit::PrintInfo::PrintMode>): - Define this since PrintMode is not an enum class. * Shared/RTCPacketOptions.cpp: * Shared/SessionState.h: * Shared/TouchBarMenuItemData.h: * Shared/WebEvent.h: * Shared/WebPopupItem.cpp: (WebKit::WebPopupItem::WebPopupItem): - Fix reference to WebPopupItem::Type enum. * Shared/WebPopupItem.h: (WebKit::WebPopupItem::Type): - Convert from enum to enum class. * Shared/WebsiteData/WebsiteDataType.h: * Shared/glib/InputMethodState.h: * Shared/glib/UserMessage.h: * Shared/mac/ColorSpaceData.mm: * Shared/mac/SecItemRequestData.h: * UIProcess/mac/WebPopupMenuProxyMac.mm: (WebKit::WebPopupMenuProxyMac::populate): - Fix reference to WebPopupItem::Type enum. * WebProcess/Plugins/Plugin.cpp: * WebProcess/WebCoreSupport/WebPopupMenu.cpp: (WebKit::WebPopupMenu::populateItems): - Fix reference to WebPopupItem::Type enum. * WebProcess/WebPage/RemoteLayerTree/PlatformCAAnimationRemote.h: Canonical link: https://commits.webkit.org/225887@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@262933 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-06-12 06:02:42 +00:00
namespace WTF {
template<> struct EnumTraits<WebCore::AutofillFieldName> {
using values = EnumValues<
WebCore::AutofillFieldName,
WebCore::AutofillFieldName::None,
WebCore::AutofillFieldName::Name,
WebCore::AutofillFieldName::HonorificPrefix,
WebCore::AutofillFieldName::GivenName,
WebCore::AutofillFieldName::AdditionalName,
WebCore::AutofillFieldName::FamilyName,
WebCore::AutofillFieldName::HonorificSuffix,
WebCore::AutofillFieldName::Nickname,
WebCore::AutofillFieldName::Username,
WebCore::AutofillFieldName::NewPassword,
WebCore::AutofillFieldName::CurrentPassword,
WebCore::AutofillFieldName::OrganizationTitle,
WebCore::AutofillFieldName::Organization,
WebCore::AutofillFieldName::StreetAddress,
WebCore::AutofillFieldName::AddressLine1,
WebCore::AutofillFieldName::AddressLine2,
WebCore::AutofillFieldName::AddressLine3,
WebCore::AutofillFieldName::AddressLevel4,
WebCore::AutofillFieldName::AddressLevel3,
WebCore::AutofillFieldName::AddressLevel2,
WebCore::AutofillFieldName::AddressLevel1,
WebCore::AutofillFieldName::Country,
WebCore::AutofillFieldName::CountryName,
WebCore::AutofillFieldName::PostalCode,
WebCore::AutofillFieldName::CcName,
WebCore::AutofillFieldName::CcGivenName,
WebCore::AutofillFieldName::CcAdditionalName,
WebCore::AutofillFieldName::CcFamilyName,
WebCore::AutofillFieldName::CcNumber,
WebCore::AutofillFieldName::CcExp,
WebCore::AutofillFieldName::CcExpMonth,
WebCore::AutofillFieldName::CcExpYear,
WebCore::AutofillFieldName::CcCsc,
WebCore::AutofillFieldName::CcType,
WebCore::AutofillFieldName::TransactionCurrency,
WebCore::AutofillFieldName::TransactionAmount,
WebCore::AutofillFieldName::Language,
WebCore::AutofillFieldName::Bday,
WebCore::AutofillFieldName::BdayDay,
WebCore::AutofillFieldName::BdayMonth,
WebCore::AutofillFieldName::BdayYear,
WebCore::AutofillFieldName::Sex,
WebCore::AutofillFieldName::URL,
WebCore::AutofillFieldName::Photo,
WebCore::AutofillFieldName::Tel,
WebCore::AutofillFieldName::TelCountryCode,
WebCore::AutofillFieldName::TelNational,
WebCore::AutofillFieldName::TelAreaCode,
WebCore::AutofillFieldName::TelLocal,
WebCore::AutofillFieldName::TelLocalPrefix,
WebCore::AutofillFieldName::TelLocalSuffix,
WebCore::AutofillFieldName::TelExtension,
WebCore::AutofillFieldName::Email,
WebCore::AutofillFieldName::Impp
>;
};
} // namespace WTF