// Copyright 2020 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_AUTOFILL_PARSING_UTILS_H_ #define COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_AUTOFILL_PARSING_UTILS_H_ #include "components/autofill/core/common/dense_set.h" #include "components/autofill/core/common/form_field_data.h" namespace autofill { // The sources from which strings are matched: the field's label or its name or // id attribute value. // // For example, in // <label for="mobile">Cellphone number:</label> <input type="tel" id="mobile"> // the kLabel is "Cellphone number" and the kName is "mobile". enum class MatchAttribute { … }; // A pair of sets of MatchAttributes and FormControlTypes. struct MatchParams { … }; inline constexpr MatchParams::MatchParams(DenseSet<MatchAttribute> attributes, DenseSet<FormControlType> field_types) : … { … } inline constexpr MatchParams::MatchParams(const MatchParams&) = default; inline constexpr MatchParams& MatchParams::operator=(const MatchParams&) = default; inline constexpr MatchParams::MatchParams(MatchParams&&) = default; inline constexpr MatchParams& MatchParams::operator=(MatchParams&&) = default; // By default match label and name for <input type="text"> elements. kDefaultMatchParamsWith; constexpr MatchParams kDefaultMatchParams = …; // Structure for a better organization of data and regular expressions // for autofill regex_constants. In the future, to implement faster // changes without global updates also for having a quick possibility // to recognize incorrect matches. // // We pack this struct to minimize memory consumption of the built-in array of // MatchingPatterns (see GetMatchPatterns()), which holds several hundred // objects. // Using packed DenseSets reduces the size of the struct by 40 to 24 on 64 bit // platforms, and from 20 to 16 bytes on 32 bit platforms. struct MatchingPattern { … }; } // namespace autofill #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_FORM_PARSING_AUTOFILL_PARSING_UTILS_H_