chromium/components/autofill/core/browser/form_structure_sectioning_util.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/autofill/core/browser/form_structure_sectioning_util.h"

#include <iterator>
#include <memory>
#include <sstream>
#include <utility>

#include "base/ranges/algorithm.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/field_types.h"
#include "components/autofill/core/common/autofill_features.h"

namespace autofill {

namespace {

bool HaveSeenSimilarType(FieldType type, const FieldTypeSet& seen_types) {}

// Some forms have adjacent fields of the same or very similar type. These
// generally belong in the same section. Common examples:
//  * Forms with two email fields, where the second is meant to "confirm"
//    the first.
//  * Forms with a <select> field for states in some countries, and a freeform
//    <input> field for states in other countries. (Usually, only one of these
//    two will be visible for any given choice of country.)
//  * In Japan, forms commonly have separate inputs for phonetic names. In
//    practice this means consecutive name field types (e.g. first name and last
//    name).
bool ConsecutiveSimilarFieldType(FieldType current_type,
                                 FieldType previous_type) {}

// Sectionable fields are all the fields that are in a non-default section.
// Generally, only focusable fields are assigned a section. As an exception,
// unfocusable <select> elements get a section, as hidden <select> elements are
// common in custom select elements. To confine the impact of hidden <select>
// elements, this exception only applies if their type is actually autofillable.
bool IsSectionable(const AutofillField& field) {}

// Assign all credit card fields without a valid autocomplete attribute section
// to one, separate section based on the first credit card field.
void AssignCreditCardSections(
    base::span<const std::unique_ptr<AutofillField>> fields,
    base::flat_map<LocalFrameToken, size_t>& frame_token_ids) {}

void AssignAutocompleteSections(
    base::span<const std::unique_ptr<AutofillField>> fields) {}

void AssignFieldIdentifierSections(
    base::span<const std::unique_ptr<AutofillField>> section,
    base::flat_map<LocalFrameToken, size_t>& frame_token_ids) {}

bool BelongsToCurrentSection(const FieldTypeSet& seen_types,
                             const AutofillField& current_field,
                             const AutofillField& previous_field) {}

// Finds the first focusable field that doesn't have a section assigned.
//
// We look for a focusable, rather than sectionable, field because starting a
// section too early may also lead to finishing the section too early. In
// particular, if a hidden section is followed by an identical visible section
// and these sections contain a <select>, then the first (invisible) <select>
// would start a section and the equivalent, visible <select> would erroneously
// finish the section due to the repeated type.
base::span<const std::unique_ptr<AutofillField>>::iterator
FindBeginOfNextSection(
    base::span<const std::unique_ptr<AutofillField>>::iterator begin,
    base::span<const std::unique_ptr<AutofillField>>::iterator end) {}

// Finds the longest prefix of [begin, end) that belongs to the same section,
// according to `BelongsToCurrentSection()`.
base::span<const std::unique_ptr<AutofillField>>::iterator FindEndOfNextSection(
    base::span<const std::unique_ptr<AutofillField>>::iterator begin,
    base::span<const std::unique_ptr<AutofillField>>::iterator end) {}

}  // namespace

void AssignSections(base::span<const std::unique_ptr<AutofillField>> fields) {}

void LogSectioningMetrics(
    FormSignature form_signature,
    base::span<const std::unique_ptr<AutofillField>> fields,
    AutofillMetrics::FormInteractionsUkmLogger* form_interactions_ukm_logger) {}

uint32_t ComputeSectioningSignature(
    base::span<const std::unique_ptr<AutofillField>> fields) {}

}  // namespace autofill